1750352431@qq.com
1750352431@qq.com
  • 发布:2019-05-18 12:50
  • 更新:2019-09-10 15:18
  • 阅读:1033

【报Bug】uniapp自定义组件模式,生成微信小程序后报错,无法运行

分类:uni-app

详细问题描述

1、uniapp开发微信小程序,使用自定义组件模式
2、使用 cli命令 编译到微信开发者工具进行调试
3、看到报错信息如附件截图,导致没法使用,只能切换模板模式调试上线
4、微信开发者工具,具体报错信息如下

thirdScriptError  
Cannot read property 'data' of undefined; [Component] Lifetime Method Error @ pages/index/index#attached  
TypeError: Cannot read property 'data' of undefined  
    at VueComponent.patch [as __patch__] (http://127.0.0.1:40280/appservice/common/vendor.js:6122:42)  
    at VueComponent.Vue._update (http://127.0.0.1:40280/appservice/common/vendor.js:4585:25)  
    at VueComponent.updateComponent (http://127.0.0.1:40280/appservice/common/vendor.js:6171:14)  
    at Watcher.get (http://127.0.0.1:40280/appservice/common/vendor.js:5012:31)  
    at new Watcher (http://127.0.0.1:40280/appservice/common/vendor.js:5001:51)  
    at mountComponent$1 (http://127.0.0.1:40280/appservice/common/vendor.js:6177:9)  
    at VueComponent.Vue.$mount (http://127.0.0.1:40280/appservice/common/vendor.js:6427:16)  
    at H.initVm$1 (http://127.0.0.1:40280/appservice/common/vendor.js:903:16)  
    at H.attached (http://127.0.0.1:40280/appservice/common/vendor.js:926:22)  
    at r.safeCallback (http://127.0.0.1:40280/appservice/__dev__/WAService.js:1:759795)

IDE运行环境说明

HBuilderX 1.9.4
macOS 10.13.6

uni-app运行环境说明

1、微信小程序
2、cli创建,已更新最新cli
3、package.json如下:
4、使用自定义组件模式

 "dependencies": {  
    "@dcloudio/uni-app-plus": "0.0.223",  
    "@dcloudio/uni-h5": "^0.4.9",  
    "@dcloudio/uni-mp-alipay": "0.0.801",  
    "@dcloudio/uni-mp-baidu": "0.0.818",  
    "@dcloudio/uni-mp-toutiao": "0.0.318",  
    "@dcloudio/uni-mp-weixin": "0.0.942",  
    "core-js": "^2.6.5",  
    "dayjs": "^1.8.14",  
    "flyio": "^0.6.2",  
    "vue": "^2.6.6",  
    "vuex": "^3.1.1"  
  },  
  "devDependencies": {  
    "@dcloudio/uni-cli-shared": "^0.2.949",  
    "@dcloudio/uni-template-compiler": "^0.9.170",  
    "@dcloudio/uni-ui": "0.0.7",  
    "@dcloudio/vue-cli-plugin-hbuilderx": "^0.9.510",  
    "@dcloudio/vue-cli-plugin-uni": "^0.9.464",  
    "@dcloudio/webpack-uni-mp-loader": "^0.3.623",  
    "@dcloudio/webpack-uni-pages-loader": "^0.2.828",  
    "@types/html5plus": "*",  
    "@types/uni-app": "^1.0.1",  
    "@vue/cli-plugin-babel": "3.5.1",  
    "@vue/cli-service": "^3.7.0",  
    "babel-plugin-import": "^1.11.2",  
    "loadjs": "^3.6.1",  
    "node-sass": "^4.12.0",  
    "sass-loader": "^7.1.0",  
    "vue-template-compiler": "^2.5.21",  
    "weex-vue-loader": "^0.7.0"  
  }

[模拟器型号]
微信开发者工具版本:1.02.1904090

附件

报错信息及代码,看附件

联系方式

[QQ] 1750352431

2019-05-18 12:50 负责人:无 分享
已邀请:
DCloud_UNI_FXY

DCloud_UNI_FXY

你的 cli 环境版本太老了。
建议,重新执行:vue create -p dcloudio/uni-preset-vue
创建一个新的工程,然后把老的 src 替换,编译测试下

  • 1750352431@qq.com (作者)

    按照您说的更新后,自定义组件模式正常构建,微信小程序可以打包了,非常感谢!!!祝uni越来越好!

    2019-05-18 17:08

小小春啊

小小春啊

我是之前创建的项目 ,现在运行到微信小程序 调用公共方法出错了,h5都没问题,我看了下现在创建的项目目录 和我之前的 有很大的区别 该怎么办啊

要回复问题请先登录注册