uni-app 微信小程序 slot 传值结构白屏报错

uni-app 微信小程序 slot 传值结构白屏报错

操作步骤:

  • 直接编译就报错,只要传结构

预期结果:

  • 预期数据能显示,H5正常

实际结果:

VM492:1507 页面【pages/home/index-scroll-list-wrapper-dataList]错误:  
TypeError: wx.createComponent is not a function  
    at index-scroll-list-wrapper-dataList.js? [sm]:2  
    at require (WAService.js:1)  
    at <anonymous>:1504:7  
    at doWhenAllScriptLoaded (<anonymous>:1609:21)  
    at Object.scriptLoaded (<anonymous>:1637:5)  
    at Object.<anonymous> (<anonymous>:1662:22)(env: Windows,mp,1.05.2110110; lib: 2.8.3)  

WAService.js:1 thirdScriptError   
sdk uncaught third Error   
wx.createComponent is not a function   
TypeError: wx.createComponent is not a function  
    at http://127.0.0.1:56251/appservice/pages/home/index-scroll-list-wrapper-dataList.js:4:4  
    at require (WAService.js:1:1442918)  
    at <anonymous>:1504:7  
    at doWhenAllScriptLoaded (<anonymous>:1609:21)  
    at Object.scriptLoaded (<anonymous>:1637:5)  
    at Object.<anonymous> (<anonymous>:1662:22)(env: Windows,mp,1.05.2110110; lib: 2.8.3)

bug描述:

  • 插槽无法对外传值
  • 只要写了结构,直接小程序报错
<ScrollListWrapper  
  @reachBottomCb="reachBottomCb"  
  :fetchDataMethod="fetchDataMethod"  
>  
  <template v-slot:dataList="{youName}"  >  
      <view>{{ youName }}</view>  
  </template>  
</ScrollListWrapper>
<div class="DATA_WRAPPER">  
  <slot name="dataList" :youName="'chenxuxin'" >  
  </slot>  
</div>
VM492:1507 页面【pages/home/index-scroll-list-wrapper-dataList]错误:  
TypeError: wx.createComponent is not a function  
    at index-scroll-list-wrapper-dataList.js? [sm]:2  
    at require (WAService.js:1)  
    at <anonymous>:1504:7  
    at doWhenAllScriptLoaded (<anonymous>:1609:21)  
    at Object.scriptLoaded (<anonymous>:1637:5)  
    at Object.<anonymous> (<anonymous>:1662:22)(env: Windows,mp,1.05.2110110; lib: 2.8.3)  

WAService.js:1 thirdScriptError   
sdk uncaught third Error   
wx.createComponent is not a function   
TypeError: wx.createComponent is not a function  
    at http://127.0.0.1:56251/appservice/pages/home/index-scroll-list-wrapper-dataList.js:4:4  
    at require (WAService.js:1:1442918)  
    at <anonymous>:1504:7  
    at doWhenAllScriptLoaded (<anonymous>:1609:21)  
    at Object.scriptLoaded (<anonymous>:1637:5)  
    at Object.<anonymous> (<anonymous>:1662:22)(env: Windows,mp,1.05.2110110; lib: 2.8.3)

更多关于uni-app 微信小程序 slot 传值结构白屏报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

我也遇到这个问题 解决了吗

更多关于uni-app 微信小程序 slot 传值结构白屏报错的实战教程也可以访问 https://www.itying.com/category-93-b0.html


解决了,更新 uni-app 版本, npx @dcloudio/uvm alpha

我把Hbuilder X插件中的uni-app (vue3)编译器卸载之后解决了

这个问题是由于微信小程序基础库版本不兼容导致的。wx.createComponent is not a function 错误通常出现在使用作用域插槽(scoped slot)时,微信小程序基础库版本较低无法支持该特性。

从错误信息可以看到你的微信开发者工具使用的是 lib: 2.8.3,这个版本相对较旧。作用域插槽在微信小程序中的支持需要较高的基础库版本。

解决方案:

  1. 升级微信开发者工具:更新到最新版本的微信开发者工具
  2. 调整基础库版本:在微信开发者工具中,进入详情 -> 本地设置,将调试基础库版本设置为 2.11.0 或更高版本
  3. 检查项目配置:在 manifest.json 中确认微信小程序配置的基础库版本:
{
  "mp-weixin": {
    "setting": {
      "urlCheck": false,
      "minified": true
    },
    "usingComponents": true,
    "libVersion": "2.11.0"
  }
}
回到顶部