vue2 页面跳转其他页面后 选中项仍高亮

在这里插入图片描述
在菜单栏的组件中给 :default-active="getActive"事件判断是否是跳转其他页面 ------>代码如下

demo
<el-menu
  :default-active="activeMenu"
  .........
>
</el-menu>
script
activeMenu() {
    
    
      if (this.$route.path === '/index5/ruleCheck' || this.$route.path === '/index5/ruleDetail' || this.$route.path === '/index5/auditissue' || this.$route.path === '/index5/testBench' || this.$route.path === '/index5/ruleAttribute') {
    
    
        return '/index2/ruleDevelopment'
      } else {
    
    
        return this.$route.path
      }
    },

判断如果跳转到了想要跳转的页面时,返回要选中的那层路径,else是为了跳转其他页面时,对应导航栏要选中的选项。

猜你喜欢

转载自blog.csdn.net/GikQxx21_wen/article/details/130385871
今日推荐