el-menu使用router后激活菜单文字颜色无法显示
在el-menu中加上
:default-active=“this.$route.path”
<el-menu
router
class="el-menu-demo" mode="horizontal"
@select="handleSelect"
background-color="#545c64"
text-color="#fff"
active-text-color="#ffd04b"
:default-active="this.$route.path">
this.$route.path会获取当前路由路径,再使用默认激活的方式去激活当前已选菜单。
本文介绍如何在Element UI的el-menu组件中使用router并设置默认激活项的文字颜色。通过使用:default-active属性并将其绑定到this.$route.path,可以确保菜单项能够根据当前路由正确高亮。
569






