vue tab切换

tab切换:

<html>

<div class="class-list">
<div class="name">品牌分类:</div>
<!--<span class="first-select select">全部</span>-->
<span @click="companyType(index)" ref="companyType" v-for="(item,index) in brand" v-bind:key="item.id"
:class="index == 0? 'first-selectd' : 'selectd'">{{item.name}}</span>
</div>
</html>
 
<js>
companyTypeEvent(index) {
this.$refs.companyType.forEach((ele, Mindex) => {
index === Mindex ? (this.$refs.companyType[Mindex].style.color = '#F9BE04')
: (this.$refs.companyType[Mindex].style.color = '#D3D3D2')

index === Mindex ? (this.$refs.companyType[Mindex].style.border = '1px solid #F9BE04')
: (this.$refs.companyType[Mindex].style.border = '1px solid #D3D3D2')
})
 
},
</js>
原文地址:https://www.cnblogs.com/httpL/p/8808688.html