在项目中使用elementui框架中的路由。其中default-active控制导航栏栏目是否跟随页面亮。
解决:
将default-active绑定自定义的path值,在方法中通过this.$route.path获取当前页面的路由,比对当前页面的路由和获取的路由是否相同,如果不相同,则跳转到指定的路由。
created() {
this.path =this.$route.path
},
methods(){
changeA(indexX){
if(this.$route.path !==indexX)
this.$router.push({path:indexX})
},
}
以上代码仅供个人记录以及复习使用,欢迎大家评论指正