刚刚更新了hx2.0,之前的代码都开始报错了 之前都没问题
p://ready:1
10:14:27.490 For developer:Do not set same key "1" in wx:key. at uniapp://ready:1
- 发布:2019-06-15 10:16
- 更新:2019-06-15 12:36
- 阅读:826
升级到hx2.0之后,官方的grid组件也报错了,,一行代码没改在hx1.9.7就没问题,好在我升级之前备份了1.9.7,现在又退回1.9.7工作了
-
回复 DCloud_UNI_HT: 1.97好的,2.0(0610,0614)都报错了,这个uni-grid组件是从官方的demo里复制出来的,没有做过修改
VM83:1 [Vue warn]: Error in created hook: "TypeError: Cannot read property 'length' of undefined"
found in
---> components/uni-grid/uni-grid
pages/home/home
console.error @ VM83:1
warn @ vendor.js:sourcemap:16873
logError @ vendor.js:sourcemap:18141
globalHandleError @ vendor.js:sourcemap:18136
handleError @ vendor.js:sourcemap:18096
invokeWithErrorHandling @ vendor.js:sourcemap:18119
callHook @ vendor.js:sourcemap:20354
Vue._init @ vendor.js:sourcemap:21148
VueComponent @ vendor.js:sourcemap:21294
attached @ vendor.js:sourcemap:16078
r.safeCallback @ WAService.js:1
r.call @ WAService.js:1
r @ WAService.js:1
r @ WAService.js:1
r @ WAService.js:1
r @ WAService.js:1
S @ WAService.js:1
m.pretendAttached @ WAService.js:1
t.attachView @ WAService.js:1
kt @ WAService.js:1
(anonymous) @ WAService.js:1
Tt @ WAService.js:1
(anonymous) @ WAService.js:1
(anonymous) @ WAService.js:1
i.emit @ WAService.js:1
emit @ WAService.js:1
(anonymous) @ WAService.js:1
(anonymous) @ WAService.js:1
e @ appservice?t=1560647331761:3511
n.registerCallback.t @ appservice?t=1560647331761:3511
u.forEach.t @ appservice?t=1560647331761:3511
(anonymous) @ appservice?t=1560647331761:3511
a.onmessage @ appservice?t=1560647331761:3511
VM83:1 thirdScriptError
Cannot read property 'length' of undefined; [Component] Lifetime Method Error @ components/uni-grid/uni-grid#attached
TypeError: Cannot read property 'length' of undefined
at VueComponent.created (http://127.0.0.1:19538/appservice/components/uni-grid/uni-grid.js:176:46)
at invokeWithErrorHandling (http://127.0.0.1:19538/appservice/common/vendor.js:18111:57)
at callHook (http://127.0.0.1:19538/appservice/common/vendor.js:20354:7)
at VueComponent.Vue._init (http://127.0.0.1:19538/appservice/common/vendor.js:21148:35)
at new VueComponent (http://127.0.0.1:19538/appservice/common/vendor.js:21294:12)
at H.attached (http://127.0.0.1:19538/appservice/common/vendor.js:16078:20)
at r.safeCallback (http://127.0.0.1:19538/appservice/dev/WAService.js:1:818220)
at r.call (http://127.0.0.1:19538/appservice/dev/WAService.js:1:818113)
at r (http://127.0.0.1:19538/appservice/dev/WAService.js:1:889956)
at r (http://127.0.0.1:19538/appservice/dev/WAService.js:1:890271)2019-06-16 09:12
-
之前忙着开发,没来得及做测试,今天刚好空了试了下,单独把uniGrid拿出来,放在一个单独的空项目里,测试出原因了,编译模式是:【自定义组件模式】
<uni-grid :options="data1" @click="onClick" />
如果data1在data()里设置为 data1:[],然后在onLoad里动态初始化,就会报错,如果在data()里随便写点内容,比如:
····
gridList: [
{
"catalog_id": "00001",
"catalog_name": "大类一",
},
{
"catalog_id": "00002",
"catalog_name": "大类二",
},
{
"catalog_id": "00003",
"catalog_name": "大类三",
},
{
"catalog_id": "00000",
"catalog_name": "更多"
}
····
然后再在onLoad里填实际的内容,hbx2.0.1就不出错了,但是在hbx1.9.7在data()里直接填一个空数组也不报错,反正已经解决了,刚好也知道了一下“自定义组件模式”。
2019-06-25 10:51
倒影 (作者)
应该是运行时报错,项目能跑起来的,就是会报错
2019-06-15 11:38