<div class="class-list"
v-for="(value, key) in list"
:key="key">
<h3>{{value.title}}</h3>
<span
class="class-item"
:class="{active: index === isActive}"
v-for="(item,index) in value.items"
:key="item"
@click="handleSortItemClick(index,value)"
>{{item}}
</span>
</div>
the data structure is like this
"list": {
"trade": {
"title":"",
"items":["","","3C","","","/","/","/","","/",""]
},
"fn":{
"title":"",
"items":["","","","","","","","","","","",""]
},
"area":{
"title":"",
"items":["","","","","","","","","",""]
}
}
how to write in the click event how to write three categories to add active, without affecting each other. If you write three loops separately, you can achieve the expected results, but the code is stupid and ask the gods to take a look at it
.