template Code
<template v-for="item in myList" ><!-- -->
<ul>
<span class="span_i"><i></i>{{item.CatName}}</span>
<li v-for="item1 in item.GameList" :key="item.Id" @click="check_show(item1)" :class="includes(item1)">
{{item1.Name}}
</li>
</ul>
</template>
class style function
includes(item1){
if (this.selectGame.includes(item1)){
return "on"
}else{
return ""
}
},
//
check_show(item1) {
const index1 = this.selectGame.indexOf(item1);
// let aa = { idName:item.Id,nameId:item.Name}
if(index1 > -1 ){
this.selectGame.splice(index1, 1)
}else if(this.selectGame.length < 10){
this.selectGame.push(item1);
}
},
the problem I have now is how to save this state. After refreshing the page, the "on" on the li will be reset, and even if there is data in the selectGame, it will not display "on"
.