element-ui侧边栏实现路由跳转后展开对应侧边栏:default-openeds
element-ui侧边栏实现路由跳转后展开对应侧边栏:default-openeds
当菜单是在本地写死时,如果想展开第一块内容、里面就只写1
:default-openeds="[‘1’]"
当菜单是动态获取时,点击跳转之后如何展开对应的菜单,在watch中监听路由的变化,根据菜单数据源遍历得到对应的index就可以了
解决方案:

watch:{// this.$route.path'$route.path':function(newVal,oldVal){this.openeds = []this.routes.forEach((item,index)=>{if(item.children){item.children.forEach((data) => {if(data.path === newVal){this.openeds.push(String(index))}})}})}},
实现效果:

本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
