html部分(current就是点击后的css名称)
<div v-for="(item,index) in category">
<div :class="index==cateindex?'current':''" @click="clickCate(index)">{{item.cate_name}}</div>
</div>
js部分
data() {
return {
category:[],//分类列表
cateindex:0,//分类默认选中下标
};
},
methods:{
//分类选中样式 clickCate(index){
this.cateindex=index;
}
}
css部分
css部分就是你要点击后改变的样式
示例图片:
版权声明:本站所有图片/内容除标明原创外,均来自网络转载,版权归原作者所有,如果有侵犯到您的权益,请联系本站删除,谢谢!