vue-router二级路由会加上router-link-exact-active router-link-active

vue-router二级路由会加上router-link-exact-active router-link-active
切换路由的时候,router-link-active会给二级添加,
一级路由加不上
解决方案
监听一下路由,动态添加class

			学习资讯
	data() {
		return {
			flag: true,
			flag_head: true
		}
	},
在这里插入代码片
		watch: {
			'$route' (to, from) {
				const self = this;
				console.log(self.$route.path)
				if(self.$route.path == '/information/zx_study') {
					self.flag = true;
					self.flag_head=true;
				}
				else if(self.$route.path == '/class/index_course'){
					self.flag = false;
					self.flag_head=true;
				}
				else if(self.$route.path == '/teacher/list'){
					self.flag = false;
					self.flag_head=true;
				}
				else if(self.$route.path == '/'){
					self.flag = false;
					self.flag_head=true;
				}	
				else{
					self.flag_head=false;
					self.flag = false;
				}
			}
		}

你可能感兴趣的:(前端随笔)