element-ui的<el-menu>组件的路由模式,当使用$router.push()跳转时,切换路由不高亮
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element

·
问题说明:
1.使用<el-menu>
导航菜单组件开启路由 :router="true"
2.切换路由不高亮显示
解决方法
1.使用 <el-menu>
组件的default-active
属性 设置当前index选中高亮
html部分代码
<!--activeIndex 表示当前路由地址 -->
<!-- eslint-disable 解决eslint 审查default-active属性命名的问题-->
<!-- eslint-disable -->
<el-menu
:router="true"
:default-active="activeIndex"
>
js部分代码
data () {
return {
//activeIndex 表示当前路由地址
activeIndex: this.$route.path
}
},
watch: {
$route (newVal) {
// 可以先在后台打印一下newVal.path,最后与跳转的index相对应即可
this.activeIndex = newVal.path
}
}




A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:17 天前 )
c345bb45
1 年前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 1 年前
更多推荐
所有评论(0)