首页 > 其他分享 >vue报错Error in render: “TypeError: Cannot read property ‘length‘ of undefined“

vue报错Error in render: “TypeError: Cannot read property ‘length‘ of undefined“

时间:2022-08-29 15:15:46浏览次数:93  
标签:13 TypeError undefined 46 non js 报错 iterable

最近弄安卓开发,uniapp,开发,微信小程序无任何报错,
但安卓端,报错,而且,一个错误会再报很多不相干的错误;
并不会显示代码具体报错的行数。排查费劲!!!

[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of undefined"
13:46:43.876 (found at pages/enterprise/main/patrol/patrolProcess.vue:1)
13:46:43.908 TypeError: Cannot read property 'length' of undefined
13:46:43.940 cid unmatched [object Object] at view.umd.min.js:1
13:46:43.971 TypeError: Invalid attempt to destructure non-iterable instance.

13:46:44.159 TypeError: Invalid attempt to destructure non-iterable instance.
13:46:44.191 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
13:46:44.223 cid unmatched [object Object] at view.umd.min.js:1
13:46:44.255 TypeError: Invalid attempt to destructure non-iterable instance.
13:46:44.288 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
13:46:44.318 cid unmatched [object Object] at view.umd.min.js:1
13:46:44.348 TypeError: Invalid attempt to destructure non-iterable instance.
13:46:44.379 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
13:46:44.414 cid unmatched [object Object] at view.umd.min.js:1
13:46:44.444 TypeError: Invalid attempt to destructure non-iterable instance.
13:46:44.478 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1
13:46:44.508 cid unmatched [object Object] at view.umd.min.js:1
13:46:44.538 TypeError: Invalid attempt to destructure non-iterable instance.
13:46:44.569 In order to be iterable, non-array objects must have a [Symbol.iterator]() method. at view.umd.min.js:1

vue 报错:Error in render: "TypeError: Cannot read property 'length' of undefined"

通常有两种情况:
1、在模板的html标签上使用length报错,正确代码(兼容各种数据类型):

<div class="item_list" v-if="form.checkVal !== undefined && form.checkVal.length > 0" >列表1</div>
<div class="item_list" v-else >列表2</div>

2、在js中使用length报错,正确处理如下:

 if(res.Data){
   if(res.Data.length == 1){
       this.tableData1 = res.Data[0];
   }
 }

标签:13,TypeError,undefined,46,non,js,报错,iterable
From: https://www.cnblogs.com/pansidong/p/16635994.html

相关文章