html部分
<div class="cards" v-for="(e, index) in userList" :key="index">
<div class="imges">
<img src="./img/xzh.png" alt="" class="imgselect" v-if="e.isChecked"
@click="userClick1(e, index)" />
<img src="./img/xz.png" alt="" class="imgselect" v-else @click="userClick1(e,
index)" />
<span>{{e.name}}</span>
</div>
</div>
js部分
this.userList.map((item) => {
item.isChecked = false
})
this.userList = this.current > 1 ? [...this.userList, ...res.data.records] :
res.data.records
userClick(row, index) {
if (this.userList[index].isChecked) {
this.userList[index].isChecked = false //取消
this.selectUser = {}
} else {
this.userList.map((item) => {
item.isChecked = false
})
this.userList[index].isChecked = true
this.selectUser = row
}
},
效果图