前言:react+antd实现点击按钮跳转页面,跳转代码如下:
this.props.history.push('/my/' + id)
已知my在router中已注册:
<Route path="/my/" component={My} />
解决方案:需要在router修改以下,即:
<Route path="/my//:id" component={My} />
原因:要使URL路径的一部分成为参数,需按以下格式写:
<Route path='/authors/:authorName' component={FilterBooks}/>
参考资料:https://cloud.tencent.com/developer/ask/sof/220850
其实不用上面的方案也可以通过this.props.location来获取传参。
标签:03,14,props,React,params,跳转,id,undefined From: https://www.cnblogs.com/iuniko/p/17214688.html