c***@qq.com
c***@qq.com
  • 发布:2019-04-26 21:31
  • 更新:2019-06-18 10:38
  • 阅读:1417

【报Bug】自定义组件代码行数超过一定行。安卓手机。预览报错,但是打包可以正常打包

分类:uni-app

详细问题描述

我用uni-app的安卓版本开发,当代码开发到一定程度然后真机预览突然发现报如下错误:

21:15:23.605 正在重启...
21:15:26.871 [Vue warn]: Error in created hook: "TypeError: undefined is not an object (evaluating 'this.$store.dispatch')"
21:15:26.894 15:26.749 23549 23573 I console :
21:15:26.918 15:26.749 23549 23573 I console : (found in <Root>)ERROR
21:15:26.940 TypeError: undefined is not an object (evaluating 'this.$store.dispatch')
ERROR
21:15:26.964 thirdScriptError
21:15:26.987 15:26.783 23549 23573 I console : undefined is not an object (evaluating 'this.$vm.$mp.query = args');at "pages/index/index" page lifeCycleMethod onLoad function
21:15:27.010 15:26.783 23549 23573 I console : onLoad@(global function):22247:21
21:15:27.030 15:26.783 23549 23573 I console : (global function):8:645216
21:15:27.074 15:26.783 23549 23573 I console : callPageLifeTime@(global function):8:644995
21:15:27.099 15:26.783 23549 23573 I console : Ct@(global function):8:659223
21:15:27.120 15:26.783 23549 23573 I console : xt@(global function):8:660251
21:15:27.140 15:26.783 23549 23573 I console : It@(global function):8:661546
21:15:27.164 15:26.783 23549 23573 I console : (global function):8:662408
21:15:27.185 15:26.783 23549 23573 I console : (global function):8:637278
21:15:27.207 15:26.783 23549 23573 I console : emit@(global function):8:204109
21:15:27.228 15:26.783 23549 23573 I console : emit@(global function):8:219534
21:15:27.251 15:26.783 23549 23573 I console : (global function):8:245795
21:15:27.272 15:26.783 23549 23573 I console : (global function):8:164893
21:15:27.293 15:26.783 23549 23573 I console : subscribeHandler@(global function):8:1563
21:15:27.318 15:26.783 23549 23573 I console : P@(global function):7:5118
21:15:27.341 15:26.783 23549 23573 I console : e@(global function):7:65303
21:15:27.364 15:26.783 23549 23573 I console : Un@(global function):7:77248
21:15:27.390 15:26.783 23549 23573 I console : (global function):8:844
21:15:27.410 15:26.783 23549 23573 I console : invoke@(global function):8:889
21:15:27.433 15:26.783 23549 23573 I console : invoke@(global function):8:105643
21:15:27.457 15:26.783 23549 23573 I console : X@(global function):8:163217
21:15:27.481 15:26.783 23549 23573 I console : (global function):8:170670
21:15:27.504 15:26.783 23549 23573 I console : jc@(global function):8:321057
21:15:27.524 15:26.783 23549 23573 I console : (global function):8:211062
21:15:27.544 15:26.783 23549 23573 I console : (global function):8:418091
21:15:27.568 15:26.783 23549 23573 I console : (global function):8:418133
21:15:27.591 15:26.783 23549 23573 I console : (global function):8:174603
21:15:27.611 15:26.783 23549 23573 I console : (global function):31450:22
21:15:27.631 15:26.783 23549 23573 I console : _loaded@(global function):7:10686
21:15:27.654 15:26.783 23549 23573 I console : (global function):7:7587
21:15:27.674 15:26.783 23549 23573 I console : (weex framework):1:107808
21:15:27.699 15:26.783 23549 23573 I console : consume@(weex framework):1:19850
21:15:27.745 15:26.783 23549 23573 I console : (weex framework):1:177648__ERROR

经过测试,发现如果我的代码超过一定行数(包括注释的内容),预览就会报这个错误,自定义基座和标准基座都会报错,但是我发现如果提交服务器打包,下载安装的代码是没有任何问题的,包括如果超过行数写的代码也可以生效。然后我发现如果去掉style 的scss编译选项就好了,结果第二天我再做另一个自定义组件的时候又出现这个问题,这个组件没有用SCSS 我直接把SCSS插件卸载了 仍然不能解决,没办法 我只能精简代码 控制在出错的行数之内预览编译才能通过,为了验证我的想法,我在另一个自定义组件的一个methods函数里 打了400行//test 然后编译预览, 报错了
21:23:36.053 正在重启...
21:23:39.384 [Vue warn]: Error in created hook: "TypeError: undefined is not an object (evaluating 'this.$store.dispatch')"
21:23:39.408 23:39.247 23549 23573 I console :
21:23:39.433 23:39.247 23549 23573 I console : (found in <Root>)ERROR
21:23:39.454 TypeError: undefined is not an object (evaluating 'this.$store.dispatch')
ERROR
21:23:39.475 thirdScriptError
21:23:39.500 23:39.281 23549 23573 I console : undefined is not an object (evaluating 'this.$vm.$mp.query = args');at "pages/index/index" page lifeCycleMethod onLoad function
21:23:39.525 23:39.281 23549 23573 I console : onLoad@(global function):23032:21
21:23:39.547 23:39.281 23549 23573 I console : (global function):8:645216
21:23:39.594 23:39.281 23549 23573 I console : callPageLifeTime@(global function):8:644995
21:23:39.614 23:39.281 23549 23573 I console : Ct@(global function):8:659223
21:23:39.637 23:39.281 23549 23573 I console : xt@(global function):8:660251
21:23:39.662 23:39.281 23549 23573 I console : It@(global function):8:661546
21:23:39.686 23:39.281 23549 23573 I console : (global function):8:662408
21:23:39.708 23:39.281 23549 23573 I console : (global function):8:637278
21:23:39.738 23:39.281 23549 23573 I console : emit@(global function):8:204109
21:23:39.759 23:39.281 23549 23573 I console : emit@(global function):8:219534
21:23:39.775 23:39.281 23549 23573 I console : (global function):8:245795
21:23:39.797 23:39.281 23549 23573 I console : (global function):8:164893
21:23:39.820 23:39.281 23549 23573 I console : subscribeHandler@(global function):8:1563
21:23:39.843 23:39.281 23549 23573 I console : P@(global function):7:5118
21:23:39.868 23:39.281 23549 23573 I console : e@(global function):7:65303
21:23:39.894 23:39.281 23549 23573 I console : Un@(global function):7:77248
21:23:39.913 23:39.281 23549 23573 I console : (global function):8:844
21:23:39.936 23:39.281 23549 23573 I console : invoke@(global function):8:889
21:23:39.959 23:39.281 23549 23573 I console : invoke@(global function):8:105643
21:23:39.985 23:39.281 23549 23573 I console : X@(global function):8:163217
21:23:40.008 23:39.281 23549 23573 I console : (global function):8:170670
21:23:40.033 23:39.281 23549 23573 I console : jc@(global function):8:321057
21:23:40.053 23:39.281 23549 23573 I console : (global function):8:211062
21:23:40.075 23:39.281 23549 23573 I console : (global function):8:418091
21:23:40.099 23:39.281 23549 23573 I console : (global function):8:418133
21:23:40.121 23:39.281 23549 23573 I console : (global function):8:174603
21:23:40.144 23:39.281 23549 23573 I console : (global function):32413:22
21:23:40.168 23:39.281 23549 23573 I console : _loaded@(global function):7:10686
21:23:40.188 23:39.281 23549 23573 I console : (global function):7:7587
21:23:40.208 23:39.281 23549 23573 I console : (weex framework):1:107808
21:23:40.238 23:39.281 23549 23573 I console : consume@(weex framework):1:19850
21:23:40.275 23:39.281 23549 23573 I console : (weex framework):1:177648__ERROR

IDE运行环境说明

完全用MAC的HBuilderX开发,更新到最新版本

[IDE版本号]
HBuilder X 1.9.3.20190422

[mac版本号]
10.14.4 (18E226)

uni-app运行环境说明

安卓真机调试

项目是HBuilderX创建

编译模式是自定义组件

App运行环境说明

[手机型号]
魅族 M816Q

HBuilderX里没有这两天的日志

联系方式

[QQ] 2051786

2019-04-26 21:31 负责人:无 分享
已邀请:
c***@qq.com

c***@qq.com (作者)

最新情况:
我又发现这次问题出在vuex的mapState方法,我把这个页面的computed里...mapState映射的内容少写几个 就不报错了。。。。


抱歉,刚发现原来并没有好 又写了十几行代码,预览编译发现又出现这个问题了。。。。。

c***@qq.com

c***@qq.com (作者)

再次关注这个问题

hackyo_ma

hackyo_ma

和你相同的问题,希望官方可以关注一下。

该问题目前已经被锁定, 无法添加新回复