el-menu-item index的值,我这里使用了 路由表中route.js中 的 路由name值
:default-active="this.$route.name"
如果不理解,可以看下 watch 监听 的 $route
<el-menu
class="el-menu-vertical-demo"
background-color="#324057"
text-color="#fff"
active-text-color="#409eff"
mode="vertical"
router
:default-active="this.$route.name"
>
<el-menu-item index="home">
<i class="el-icon-s-home"></i>
<span slot="title">首页</span>
</el-menu-item>
<el-menu-item index="foundlist">
<i class="el-icon-s-order"></i>
<span slot="title">信息查询</span>
</el-menu-item>
<el-menu-item index="infoshow">
<i class="el-icon-user-solid"></i>
<span slot="title">个人信息</span>
</el-menu-item>
</el-menu>
export default {
name: "left-menu",
data() {
return {};
},
computed: {},
methods: {},
watch: {
$route(to,from){
// console.log(to)
console.log(`前往路由:${to.path}`);
}
}
};