照相
照相
  • 发布:2022-06-20 12:04
  • 更新:2022-06-20 12:04
  • 阅读:690

在微信小程序中,通过for循环slot插入cell的方式,通过switch修改item内部变量,内部变量修改无效,在浏览器中正常

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: 12.3

HBuilderX类型: 正式

HBuilderX版本号: 3.4.15

第三方开发者工具版本号: 1.06.2206090 Stable

基础库版本号: 2.24.5

项目创建方式: HBuilderX

示例代码:

list组件:

<template>  
    <view>  
        <view v-for="(item,index) in list" :key="index">  
            <slot name="cell" :item="item" :index="index" />  
        </view>  
    </view>  
</template>  

<script>  
    export default {  
        name:"list",  
        data() {  
            return {  
                list: [{status:false},{status:false},{status:false}]  
            };  
        }  
    }  
</script>  

<style>  

</style>

页面代码:

<template>  
    <view class="content">  
        <list>  
            <view class="item" slot="cell" slot-scope="{item,index}" >  
                <switch :checked="item.status" @change="(e)=>{switchChange(e,item)}" />  
                switch状态:{{item.status}}  
            </view>  
        </list>  
    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                title: 'Hello'  
            }  
        },  
        onLoad() {  

        },  
        methods: {  
            switchChange(e,item){  
                this.$set(item,'status',e.detail.value);  
            }  
        }  
    }  
</script>  

<style>  
    .item{  
        padding: 40rpx;  
        border-bottom: solid 1px #eeeeee;  
    }  
</style>  

操作步骤:

运行demo项目在微信小程序平台,点击任意一个switch开关,右侧文字依然为:switch状态:false,而非switch状态:true。在h5中正常

预期结果:

运行demo项目在微信小程序平台,点击任意一个switch开关,右侧文字应当为:switch状态:true

实际结果:

运行demo项目在微信小程序平台,点击任意一个switch开关,右侧文字依然为:switch状态:false,而非switch状态:true。在h5中正常

bug描述:

在微信小程序中,通过for循环slot插入cell的方式,通过switch修改item内部变量,内部变量修改无效,在浏览器中正常

2022-06-20 12:04 负责人:无 分享
已邀请:

要回复问题请先登录注册