React坑(一):解决使用 <NavLink to="/home1" activeClassName="selected"> 中选中样式不生效报错

发布时间:2022-06-28 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了React坑(一):解决使用 <NavLink to="/home1" activeClassName="selected"> 中选中样式不生效报错脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

源码:

<NavLink to="/home1" activeClassName="selected"> 主页一</NavLink>
        <NavLink activeStyle={{
            fontWeight: 'bold',
            color: 'red'}}
          to="/home2"> 主页二
        </NavLink>

报错:

index.js:1 Warning: React does not recognize the `activeClassName` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `activeclassname` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

 

React坑(一):解决使用 <NavLink to="/home1" activeClassName="selected"> 中选中样式不生效报错

 

首先检查你的版本:

v6以上版本 都会报这个错,改回v5就行,同时如果使用<Routes>请删除,这个时v6的属性

React坑(一):解决使用 <NavLink to="/home1" activeClassName="selected"> 中选中样式不生效报错

 

脚本宝典总结

以上是脚本宝典为你收集整理的React坑(一):解决使用 <NavLink to="/home1" activeClassName="selected"> 中选中样式不生效报错全部内容,希望文章能够帮你解决React坑(一):解决使用 <NavLink to="/home1" activeClassName="selected"> 中选中样式不生效报错所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: