[英]React router activeClassName doesnt set active class for child routes
<ul className="right hide-on-med-and-down">
<li><IndexLink to="/" activeClassName="active">ABOUT</IndexLink></li>
<li><Link to="blog" activeClassName="active">BLOG</Link></li>
<li><Link to="discover" activeClassName="active">DISCOVER</Link></li>
<li><Link to="contact" activeClassName="active">CONTACT</Link></li>
</ul>
this is how my navigation looks like, and when i navigate to /blog, Blog is active. 这就是我的导航的样子,当我导航到/博客时,博客是活跃的。 but when i navigate to /blog/my-blog-post, the active class disappears, is there a way to make /blog/my-blog-post set the active class on my blog list item?
但当我导航到/ blog / my-blog-post时,活动类消失了,有没有办法让/ blog / my-blog-post在我的博客列表项上设置活动类?
<Route path="blog" component={Blog}>
<Route path=":slug" component={Blog}></Route>
</Route>
I just had to declare my routes as above and it worked! 我只需要在上面声明我的路线并且它有效! This link was helpful:
https://github.com/reactjs/react-router/issues/1684
这个链接很有帮助:
https://github.com/reactjs/react-router/issues/1684
: https://github.com/reactjs/react-router/issues/1684
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.