data里isActive:-1,method里
checkedItem(index){ this.isActive=index;},页面里
<div v-for="(item,index) in nameoptions" v-bind:class="{active:index==isActive}" @click="checkItem(index)>{{item.name}}</div>
时间: 2024-10-11 11:49:03
data里isActive:-1,method里
checkedItem(index){ this.isActive=index;},页面里
<div v-for="(item,index) in nameoptions" v-bind:class="{active:index==isActive}" @click="checkItem(index)>{{item.name}}</div>