美文网首页
函数式组件(无状态)的路由跳转

函数式组件(无状态)的路由跳转

作者: 懒懒猫 | 来源:发表于2022-03-09 17:38 被阅读0次

来源于:https://blog.csdn.net/weixin_45264424/article/details/120000759

使用 useHistory:

import { Route, useHistory } from "react-router-dom";
function App() {
    const goDetail = (testPlanNumber) => {
    history.push(`/app/testing/plan/${testPlanNumber}`)
  }
    }
    return (
      <div>
    <Button onClick={() => goDetail(record.testPlanNumber)}>详情</Button>
      </div>  );
 }
    
export default App;

使用withRouter:

import { Route, withRouter} from "react-router-dom";
function App(props) {
    const goDetail = (testPlanNumber) => {
   props.history.push(`/app/testing/plan/${testPlanNumber}`)
  }
    }
    return (
      <div>
    <Button onClick={() => goDetail(record.testPlanNumber)}>详情</Button>
      </div>  );
 }
    
export default App;

相关文章

  • 函数式组件(无状态)的路由跳转

    来源于:https://blog.csdn.net/weixin_45264424/article/details...

  • vue之routerView源码解析

    routerView 视图渲染 核心就是根据路由匹配到视图,并且渲染到页面上 函数式组件,特点:没有状态,函数没有...

  • 函数式组件

    函数式组件 函数式组件,即无状态,无法实例化,内部没...

  • vue 路由传递参数

    父组件: 跳转路由子组件:

  • Vue实战第二天

    路由组件传参 动态路由传参 静态路由传参 函数传参htm5 history 模式 设置通用路由,找不到页面跳转自定...

  • Vue.js 2函数式组件学习

    什么是函数式组件? 函数式组件就是函数是组件,组件是函数,它的特征是没有内部状态、没有生命周期钩子函数、没有thi...

  • React创建组件的几种方式与优缺点

    React有三种创建组件的方式: 一、无状态函数式组件:无状态函数式组件表现为只带一个render方法的组件。 特...

  • vue高阶

    组件 动画 插件 过滤器 复用 路由 状态 响应式原理

  • 路由模块

    路由模块控制vue内容显示,路由跳转,组件间的跳转。就是一个页面中实现不同组件内容的切换 1. 安装路由模块 ...

  • 函数式组件 Functional Components

    在Vue 2中,函数式组件主要有两个用途: 性能优化,函数式组件初始化速度远远快于状态式组件( stateful ...

网友评论

      本文标题:函数式组件(无状态)的路由跳转

      本文链接:https://www.haomeiwen.com/subject/nmddrrtx.html