您的位置:首页 > Web前端 > Vue.js

vue点击菜单跳转时,背景颜色动态变化

2019-06-18 15:40 12 查看

**

vue点击菜单跳转时,背景颜色动态变化

**

html:

script:

export default {
name: “menu”,
data() {
return {
activeKey: 0
}
},
methods: {
onclick(index) {
this.KaTeX parse error: Expected '}', got 'EOF' at end of input: … this.router.push(’/menu1’)
}else if ( index == 1){
this.KaTeX parse error: Expected 'EOF', got '}' at position 31: …enu3') }̲else if ( index…router.push(’/menu3)
}else if ( index == 3){
this.KaTeX parse error: Expected 'EOF', got '}' at position 31: …enu4') }̲else if ( index…router.push(’/’)
}
},
}
}

css:

.Active{
background-color: rgba(9, 43, 89, 0.95);
color: #fff;
}

store:

const state = {
Active:0,
};

方法是实现了,但是还是有bug,刷新后背景颜色会回到默认的菜单栏,不会随路由改变,有好的解决办法的欢迎交流(参照同学教的点击跳转改变背景颜色)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: