lijunshuai
lijunshuai
  • 发布:2020-03-19 23:03
  • 更新:2020-03-20 11:29
  • 阅读:884

v-for点击事件后页面无法重新渲染

分类:HBuilderX

<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>

2020-03-19 23:03 负责人:无 分享
已邀请:
秋云1

秋云1

数组用splice修改才会刷新

lijunshuai

lijunshuai (作者) - 没有

可以了,非常感谢!

该问题目前已经被锁定, 无法添加新回复