<ul class="nij"> <li v-for="item in nav" @click="selectNav(item.title)"> <p :class="isSelect === item.title ? ‘active‘ : ‘‘">{{item.title}}</p> </li> </ul>
data:function(){
return{
isSelect: ‘senUs‘,
nav: [
{title: ‘senUs‘},
{title: ‘senGermany‘},
{title: ‘senFrance‘},
{title: ‘senUk‘}
]
}
},
methods:{ selectNav (title) { var that=this; this.$nextTick(function(){ that.isSelect = that.$route.name }) switch (title) { case ‘senUs‘: this.$router.push(‘/sentiSectors/senUs‘) break case ‘senGermany‘: this.$router.push(‘/sentiSectors/senGermany‘) break case ‘senFrance‘: this.$router.push(‘/sentiSectors/senFrance‘) break case ‘senUk‘: this.$router.push(‘/sentiSectors/senUk‘) break } } }, mounted(){ this.isSelect = this.$route.name; },
.nij{ p{ line-height:30px; } } .active{ color: #ffd100; }
原文地址:https://www.cnblogs.com/rachelch/p/8320437.html
时间: 2024-11-05 12:32:49