首页 > 其他 > 详细

React router 4 获取路由参数,跨页面参数

时间:2018-10-10 10:05:25      阅读:476      评论:0      收藏:0      [点我收藏+]
1. match通过路径
<Route path="/path/:name" component={example} />
路由组件内获取参数使用
this.props.match.params.name
2. query String 通过search
//mirrorx中使用push的参数search,link中使用与此类似
actions.routing.push({
  pathname: ‘/path/example‘,
  search: `?name={name}`,
 }
)
路由组件内获取参数使用
this.props.location.search
是个字符串,可以使用querySrirng方法来获取指定参数
原来this.props.location.query.name这种方式在v4版本中不再可用,老版本获取参数方式

React router 4 获取路由参数,跨页面参数

原文:https://www.cnblogs.com/mengff/p/9764617.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!