uni-app 3.1.20和3.1.19 版本作用域卡槽(v-slot)编译到微信端报错,编译到其他端均正常,3.1.18 版本可以正常编译到微信端

uni-app 3.1.20和3.1.19 版本作用域卡槽(v-slot)编译到微信端报错,编译到其他端均正常,3.1.18 版本可以正常编译到微信端

产品分类

uniapp/小程序/微信

PC开发环境操作系统

Windows

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

win10 21H1

HBuilderX类型

Alpha

HBuilderX版本号

3.1.19

第三方开发者工具版本号

1.05.2106091

基础库版本号

2.17.0

项目创建方式

HBuilderX

示例代码

卡槽部分 (goods-list-item.vue)
```scss
[@import](/user/import) '@/style/popup-public-select.scss';
[@import](/user/import) '@/style/row-flex-list.scss';
<template>
    <popup-layer-view ref="scrollPopup" :zIndex="zIndex" :isMaxWidth="false">
        <view class="row-flex-list" :style="{ marginTop: !showBar && showHead ? '5px' : '15px' }">
            <view 
                class="row-flex-item" 
                v-for="(item, index) in dataList" 
                :key="index" 
                :style="{ width: itemWidth }" 
                @tap="itemTap(item, index)"
            >
                <slot :item="item" :index="index"></slot>
            </view>
        </view>
    </popup-layer-view>
</template>

<script src="./popup-public-select.js"></script>

调用部分

<style lang="scss" src="./select-goods-popup.scss"></style>
<template>
    <view>
        <!-- 搜商品 -->
        <popup-public-select
            ref="SS_INFO"
            :zIndex="zIndex"
            :url="all_url.SS_INFO"
            :param="all_param.SS_INFO"
            type="goods"
            search-key="mc"
            :search="all_search.SS_INFO"
            :menu-list="menuList"
            menu-show-key="c_mc"
            :ckxx="ckxxNew"
            searchPlaceholder="请输入商品信息 . . ."
        >
            <template v-slot:default="{ item }">
                <goods-list-item :item="item" :xsjg="true" icon="icon-jiahao"></goods-list-item>
            </template>
        </popup-public-select>
    </view>
</template>

<script src="./select-goods-popup.js"></script>

操作步骤

使用3.1.19 编译

预期结果

编译微信小程序成功

实际结果

编译时报错,编译微信小程序失败

bug描述

11:21:03.103 TypeError: Cannot read property 'push' of undefined
11:21:03.103     at getRenderSlot (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\render-slot.js:32:36)
...

更多关于uni-app 3.1.20和3.1.19 版本作用域卡槽(v-slot)编译到微信端报错,编译到其他端均正常,3.1.18 版本可以正常编译到微信端的实战教程也可以访问 https://www.itying.com/category-93-b0.html

5 回复

问题确认,已加分,后续优化
临时解决方案 manifest.json mp-weinx 下面配置
“scopedSlotsCompiler”: “legacy”

更多关于uni-app 3.1.20和3.1.19 版本作用域卡槽(v-slot)编译到微信端报错,编译到其他端均正常,3.1.18 版本可以正常编译到微信端的实战教程也可以访问 https://www.itying.com/category-93-b0.html


靠这个解决了编译问题

改个项目发现用了插槽作用域,结果3.1.19以下的版本不能用作用域,下个3.1.19编译直接报错

3.1.19以下是可以的呀,我是3.1.9不可以用,你是怎么写的卡槽

HBuilderX alpha 3.1.22+ 已修复

回到顶部