<li v-for="(item,index) in schoolList1" :key="index" :class="{ active:index == current }" @click="checked(index)">
{{ item.name }}
</li>
data(){
return{
current:false,
}
}
methods: {
//点击颜色改变
checked(index){
this.current=index
}
}
.active{
color:red !important;
}
这种方式写出来第一个li是直接显示颜色的,但是我不想让它显示,我只想点击的时候才会显示颜色,有什么更好的办法呢?