效果类似于点击选择标签 首次点击高亮再点击取消 可多选 ;
上代码 templete部分:
<ol>
<li v-for="n in 6" :class='{tagActive: checkedTags[n-1]}' v-on:click="changeActive(n-1)">{
{tags[n-1]}}</li>
</ol>
js部分
data(){
return {
tripInfo: this.$store.state.trip.tripInfo || null,
tags: ['', '', '', '', '', ''],
rate: 4,
checkedTags: {}
},
methods:{
changeActive (n) {
this.$set(this.checkedTags, n, !this.checkedTags[n])
}
}
牵扯到$set的用法 找到的文献,直接拷过来 恩 要让前辈的努力继承下去