首先先看一下我的inedx.js入口文件:

解决react-router 的activeClassName 首页重复匹配问题-LMLPHP

这是未点击的时候解决react-router 的activeClassName 首页重复匹配问题-LMLPHPindex默认的是选中状态,

这是我点击其他的路由之后:解决react-router 的activeClassName 首页重复匹配问题-LMLPHP,明显index路由重复了,仔细看了官方文档之后,发现其实Navlink也应该使用exact进行精确的匹配:

  <NavLink exact to="/" activeClassName="link-active">index</NavLink>

  

04-16 10:50