场景: 使用 element ui NavMenu 导航菜单, 跳转到子页面, 导航不高亮
解决方案
1, 使用 default-active 绑定计算属性
2, 使用 vue-router 的模式, 启用该模式会在激活导航时以 index 作为 path 进行路由跳转
image.PNG
3, 计算属性
image.PNG
- computed:{
- activeIndex() {
- const { name } = this.$route;
- switch (name) {
- case 'threemarklist':
- case 'qclist':
- return '/threemarklist';
- case 'purchaseList':
- case 'searchList':
- return '/purchaselist';
- case 'handlePic':
- return "/handlepic";
- }
- }
来源: http://www.jianshu.com/p/aad856345c1f