1、params参数
1.1路由链接(携带参数):
<Link to="/demo/test/tom/18">详细信息<Link/>
1.2注册路由(声明接收):
<Route path="/demo/test/:name/:age" component={Detail}/>
1.3接收参数:this.props.match.params
2、search参数
2.1路由链接(携带参数):
<Link to="/demo/test?name=tom&age=18">详细信息<Link/>
2.2注册路由(无需声明,正常注册即可):
<Route path="/demo/test" component={Detail}/>
2.3接收参数:this.props.location.search
2.4备注:获取到的search是urlencoded编码字符串,需要借助querystring解析
3、state参数
3.1路由链接(携带参数):
<Link to={{path:'/demo/test',state:{name:tom,age:18}}}>详细信息<Link/>
3.2注册路由(无需声明,正常注册即可):
<Route path="/demo/test" component={Detail}/>
3.3接收参数:this.props.location.state
3.4备注:虽然在浏览器地址栏不显示携带的参数,但是刷新也可以保留住参数