javascript - How to pass parameters in react-router-dom v4, and how to get parameters for the next component to jump to
怪我咯
怪我咯 2017-06-12 09:32:47
0
2
1018

Current parameter passing method:

<Link to={`/topics/${topic.id}`}>{topic.title}</Link>

1. Is the method of passing parameters correct?

Then jump to the next page, the address bar is:

http://localhost:8080/topics/33119

I thought this.props.params.id could get the parameters this way, but it doesn’t seem to work.
2. How to obtain the address bar parameters?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(2)
代言

It has been solved. It is still somewhat different from react-router. Question and answer:

1. Routing configuration

<Route path="/topics/:id" component={Topics} />

2. Page before jumping

<Link to={`/topics/${topic.id}`} >点击跳转</Link>

3. Get parameters from page topics after jumping

this.props.match.params.id
女神的闺蜜爱上我

Determine the id based on the address of the router

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!