首页 > 其他 > 详细

react动态路由传值

时间:2020-10-29 19:57:03      阅读:40      评论:0      收藏:0      [点我收藏+]

react动态路由传值

  1、动态路由配置

      <Route path="/content/:aid" component={Content} />   

  2、对应的动态路由加载的组件里面获取传值
        this.props.match.params.aid
  跳转:<Link to={`/content/${value.aid}`}>{value.title}</Link>

    react get传值  

    一步即可
   //url模块来解析url地址    在react里面使用url模块需要安装url模块    cnpm install url --save
      import url from ‘url‘;
       var query=url.parse(this.props.location.search,true).query;
     console.log(query)
  1、获取 this.props.location.search

react动态路由传值

原文:https://www.cnblogs.com/duocaishenghuo/p/13898400.html

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