在react中使用Link带参数的路由跳转

时间:2020-01-10 18:36:50   收藏:0   阅读:831

1,引入Link模块

 import { NavLink as Link } from 'react-router-dom'

2,Link标签中带上要传递的参数

<Link to={
        {
          pathname:`/要跳转的路径`,
          state:{key值:val值}
        }
      }>

3,在跳转页面接收传递的参数

componentWillMount(){
    //console.log(this.props.location)//传递过来的所有参数
    console.log(this.props.location.state.key值)//val值
}

原文:https://www.cnblogs.com/zlgblog/p/12177303.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!