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


    最近弄安卓开发,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];
       }
     }
    
  • 相关阅读:
    常见的块级元素和行级元素
    CentOS 利用 yum 安装卸载软件常用命令
    MySQL 派生表(Derived Table) Merge Optimization
    MySQL中的两种临时表
    集中化管理平台 — Ansible 详解
    MySQL 错误码对照
    mysqldump 工具使用详解——参数选项
    git 命令参考手册
    XtraBackup 备份与恢复实例讲解
    XtraBackup 原理与安装
  • 原文地址:https://www.cnblogs.com/pansidong/p/16635994.html
Copyright © 2020-2023  润新知