<template>
<view class="content">
<view v-for="(item,index) in dataList" :key="index">
<view style="display: flex;
align-items:center;">
<text>{{item.name}}</text>
<view style="margin-left: 30rpx;" @tap="itemclick(index)">
<image style="width: 32rpx;height: 32rpx;" :src="item.check?'../../static/img/select.png':'../../static/img/unselect.png'">
</image>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
dataList: []
}
},
methods: {
itemclick(index) {
this.dataList[index].check = !this.dataList[index].check
}
},
onLoad() {
for (let i = 0; i < 3; i++) {
let dataItem = {}
dataItem.name = "name" + i
dataItem.check = false
this.dataList[i] = dataItem
}
}
}
</script>
<style>
</style>
2 个回复
秋云1
数组用splice修改才会刷新
lijunshuai (作者) - 没有
可以了,非常感谢!