react 路由动态传参Link

仓库地址

https://gitee.com/zhouyunfang/react-vita/blob/master/client/src/components/profile/Profile.js

html

 //比如:profile.handle=text
更多信息

路由:

import Profile from './components/profile/Profile'
let router = [
  {//开发者更多信息
    path: '/profile/:handle',//动态传参,
    componentName: Profile,
    auth: false,//是否授权
  },


];

export default router;

进入页面获取路径,带参发送请求

 componentDidMount () {
    console.log('hadle', this.props.match.params);//text
    // 获取路由传过来的动态参数
    if (this.props.match.params.handle) {
      // 带参传入发送请求
      this.props.getProfileByHandle(this.props.match.params.handle)
    }
  }

不懂路由封装请看

https://blog.csdn.net/qq_40190624/article/details/104175699

你可能感兴趣的:(React)