照相
照相
  • 发布:2023-05-30 14:53
  • 更新:2023-05-30 14:53
  • 阅读:451

在微信小程序中,若开启了slotMultipleInstance,同时通过for循环插入slot和使用slot-scope,slot插入无效

分类:uni-app

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

PC开发环境操作系统: Mac

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

HBuilderX类型: 正式

HBuilderX版本号: 3.8.3

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

基础库版本号: 2.32.0

项目创建方式: HBuilderX

示例代码:

在manifest.json中为mp-weixin设置"slotMultipleInstance" : true


子组件:list.vue

<template>  
    <view>  
        <slot name="header" :status="status"/>  
        <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 {  
                status: 1,  
                list: [1,2,3,4,5,6,7,8,9,10]  
            };  
        }  
    }  
</script>  

<style>  

</style>

页面:index.vue

<template>  
    <view class="content">  
        <list>  
            <view slot="header" slot-scope="{status}">  
                Header-{{status}}  
            </view>  
            <view class="item" slot="cell" slot-scope="{item,index}" >  
                item--{{index}}--{{title}}  
            </view>  
        </list>  
    </view>  
</template>  

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

        },  
        methods: {  

        }  
    }  
</script>  

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

操作步骤:

运行demo到微信小程序,页面空白。若删除"slotMultipleInstance" : true并重新运行,则正常。
这里是因为给header这个slot设置了slot-scope导致的。如果不给header设置slot-scope,则也正常

预期结果:

运行demo到微信小程序,应该正确显示页面数据

实际结果:

运行demo到微信小程序,页面空白

bug描述:

运行demo到微信小程序,页面空白。若删除"slotMultipleInstance" : true并重新运行,则正常。
这里是因为给header这个slot设置了slot-scope导致的。如果不给header设置slot-scope,则也正常

2023-05-30 14:53 负责人:无 分享
已邀请:

要回复问题请先登录注册