该怎么做呢?例如,我发现了以下内容:
<Link to={{pathname: "/dialog", state: { detail: message }}}>
text
</Link>但是如果我想要显示this.props.location.state,,那就写未定义的。
发布于 2018-05-28 20:24:12
传递参数
Configure your route path to accept named parameters (:id):
<Route path='/route/:id' exact component={MyComponent} />
Then you can pass URL parameters such as IDs in your link to:
<Link to={`route/foo`}>My route</Link>
You can access the parameter within your component via the match object:
const {id} = props.match.params
console.log(id) // "foo"https://stackoverflow.com/questions/50566059
复制相似问题