methods: {
getIndex() {
//头部导航样式设置:利用wacth监听,当路由发生变化 执行watch中的方法
if(this.$store.state.numStatus == 1){ //账号设置 跳至我的
this.activeclass = 4;
}else if(this.$store.state.numStatus == 2){ //退出系统 跳至首页
this.activeclass = 1;
}else if(this.$store.state.numStatus == 3 || this.$store.state.numStatus == 5){
//点击首页中的立即翻译 跳至 我的立即翻译
//点击我的模块中的去使用 跳至立即翻译
this.activeclass = 2;
}else if(this.$store.state.numStatus == 4){ //翻译时,动画消失或点击我的翻译 跳至 我的翻译
this.activeclass = 3;
}else{}
}
},
watch: {
// 如果路由有变化,会再次执行该方法
"$route": "getIndex"
}
vue中用watch监听路由变化,改变导航样式
最新推荐文章于 2024-09-12 16:17:49 发布