除了能够在 NavLink 上设置“activeClassName”和“activeStyle”之外,在非网络上创建指向其他路线的链接时,是否有任何理由使用 NavLink 而不是 Link - 网站上不需要事件状态/类的导航元素(即不是页眉或页脚中的主导航)?
最佳答案
<NavLink>
A special version of the
<Link>
that will add styling attributes to the rendered element when it matches the current URL.
因此,答案是否。除了上述原因外,没有其他原因。
关于javascript - React Router v4 <NavLink> 与 <Link> 的优点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47338077/