m***@qq.com
m***@qq.com
  • 发布:2021-06-15 11:33
  • 更新:2021-07-07 20:18
  • 阅读:673

【报Bug】 3.1.20和3.1.19 作用域卡槽(v-slot)编译到微信端报错,编译到其他端均正常,3.1.18也可以正常编译到微信端

分类:uni-app

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

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10 21H1

HBuilderX类型: Alpha

HBuilderX版本号: 3.1.19

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

基础库版本号: 2.17.0

项目创建方式: HBuilderX

示例代码:

卡槽部分 (goods-list-item.vue)

 <style lang="scss">  
@import '@/style/popup-public-select.scss';  
@import '@/style/row-flex-list.scss';  
</style>  
<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>  
        </global-page-scroll>  

    </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)
11:21:03.106 at Object.CallExpression (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\visitor.js:228:15)
11:21:03.109 at NodePath._call (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:55:20)
11:21:03.112 at NodePath.call (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:42:17)
11:21:03.116 at NodePath.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:90:31)
11:21:03.116 at TraversalContext.visitQueue (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:112:16)
11:21:03.120 at TraversalContext.visitMultiple (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:79:17)
11:21:03.120 at TraversalContext.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:138:19)
11:21:03.123 at Function.traverse.node (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\index.js:84:17)
11:21:03.124 at NodePath.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:97:18)
11:21:03.127 at TraversalContext.visitQueue (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:112:16)
11:21:03.128 at TraversalContext.visitMultiple (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:79:17)
11:21:03.132 at TraversalContext.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:138:19)
11:21:03.133 at Function.traverse.node (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\index.js:84:17)
11:21:03.136 at NodePath.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:97:18)
11:21:03.136 at TraversalContext.visitQueue (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:112:16)
11:21:03.521 TypeError: Cannot read property 'push' of undefined
11:21:03.521 at getRenderSlot (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\render-slot.js:32:36)
11:21:03.524 at Object.CallExpression (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\script\traverse\visitor.js:228:15)
11:21:03.528 at NodePath._call (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:55:20)
11:21:03.531 at NodePath.call (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:42:17)
11:21:03.535 at NodePath.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:90:31)
11:21:03.536 at TraversalContext.visitQueue (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:112:16)
11:21:03.539 at TraversalContext.visitMultiple (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:79:17)
11:21:03.565 at TraversalContext.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:138:19)
11:21:03.566 at Function.traverse.node (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\index.js:84:17)
11:21:03.569 at NodePath.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:97:18)
11:21:03.572 at TraversalContext.visitQueue (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:112:16)
11:21:03.576 at TraversalContext.visitMultiple (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:79:17)
11:21:03.580 at TraversalContext.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:138:19)
11:21:03.584 at Function.traverse.node (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\index.js:84:17)
11:21:03.591 at NodePath.visit (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\path\context.js:97:18)
11:21:03.596 at TraversalContext.visitQueue (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@babel\traverse\lib\context.js:112:16)
11:21:37.253 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):
11:21:37.257 Error: Compile failed at components/popup/popup-public-select/popup-public-select.vue
11:21:37.257 at compile (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\index.js:140:13)
11:21:37.260 at actuallyCompile (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:70:96)
11:21:37.260 at compileTemplate (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:31:16)
11:21:37.266 at Object.module.exports (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\vue-loader\lib\loaders\templateLoader.js:46:20)
11:21:37.270 Module build failed (from ./node_modules/@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/loaders/templateLoader.js):
11:21:37.273 Error: Compile failed at components/row-flex-list/row-flex-list.vue
11:21:37.276 at compile (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\uni-template-compiler\lib\index.js:140:13)
11:21:37.276 at actuallyCompile (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:70:96)
11:21:37.282 at compileTemplate (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\@vue\component-compiler-utils\dist\compileTemplate.js:31:16)
11:21:37.286 at Object.module.exports (F:\IDE\HBuilderX\plugins\uniapp-cli\node_modules\@dcloudio\vue-cli-plugin-uni\packages\vue-loader\lib\loaders\templateLoader.js:46:20)
11:21:37.563 ERROR Build failed with errors.

2021-06-15 11:33 负责人:无 分享
已邀请:
DCloud_UNI_GSQ

DCloud_UNI_GSQ

问题确认,已加分,后续优化

临时解决方案 manifest.json mp-weinx 下面配置

"scopedSlotsCompiler": "legacy"
  • 4***@qq.com

    靠这个解决了编译问题

    2021-07-07 09:39

渐进式框架

渐进式框架

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

  • m***@qq.com (作者)

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

    2021-06-17 09:05

DCloud_UNI_GSQ

DCloud_UNI_GSQ

HBuilderX alpha 3.1.22+ 已修复

要回复问题请先登录注册