侧边栏导航路由切换。

侧边栏点击路由会到用户管理页面,用户管理点击按钮能直接切换到“新建用户”上,上边会再显示一个新建用户,且侧边栏依旧为选中状态

img

img

<el-menu :default-active="getActive" class="el-menu-vertical" router></el-menu>
getActive () {
      console.log(this.$route.path)
      if (this.$route.path === '需要转高亮url') {
        return '/demo' // 需要高亮的url
      } else {
        return this.$route.path
      }
    }

如果你选中的元素会有个数组进行记录的话, 你可以通过判断这个数组是否有值 来决定 新建增加 按钮的状态
或者 设置一个标志用来记录角色是否被选中 从而来决定 新建增加 按钮的状态
方法还是比较多的