I use a router like this:
render((
<Router history={browserHistory}>
<Route path="/" component={App}>
<IndexRoute component={Home}/>
<Route path="/detail/:blogId" component={DetailView}/>
</Route>
</Router>
), document.getElementById('app'))
and in blog.js
I use Link
<Link to={{ pathname: "/detail", query: { blogId: this.props.id } }}>Detail</Link>
but it didn't work, how to replace the :blogId
part with state or props?
:blogId
is a param, not a query.
You can simply set your param in the link tag like this:
<Link to={'/detail/' + this.props.id}>Detail</Link>
Just write Var link= "detail/" + this.props.id;
Detail
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.