vue报错Error in render: "TypeError: Cannot read property '0' of undefined"
通常有两种情况:
1、在模板的html标签上使用length报错
vue 中使用 length判断的时候,有时会报错,如下:
<div class="item_list" v-if="form.checkVal.length > 0" >列表1</div>
<div class="item_list" v-else >列表2</div>
解决方法:
改成: form.checkVal !== undefined && form.checkVal.length > 0
<div class="item_list" v-if="form.checkVal !== undefind && form.checkVal.length > 0" >列表1</div>
<div class="item_list" v-else >列表2</div>
2、在js中使用length报错,如下
if(res.Data.length == 1){
this.tableData1 = res.Data[0];
}
报错原因:此时res.Data是无数据为undefined的,所以找不到 res.Data.length。
解决办法:在加一层判断,首先保证res.Data存在不为null或undefined改为,如下
if(res.Data){
if(res.Data.length == 1){
this.tableData1 = res.Data[0];
}
3.可能在data中声明了两个相同的属性,导致冲突,或者写错某个单词导致没有数据
4.判断是否存在
vue报错Error in render: "TypeError: Cannot read property '0' of undefined"的更多相关文章
- [Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined、vuejs路由使用的问题Error in render function
1.[Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined 注意,只要出现Error i ...
- Vue 报错Error in render: “TypeError: Cannot read properties of null (reading ‘xxx’)” found in
前端vue报错 [Vue warn]: Error in render: "TypeError: Cannot read properties of null (reading 'name' ...
- app.js:1274 [Vue warn]: Error in render: "TypeError: Cannot read property 'object_id' of undefined"问题小记
凌晨遇到一个控制台报错的信息,总是显示有对象中的元素未定义 明明是有把定义对象的值的,后面发现是把没有返回值的函数又赋值一遍给未定义的元素所属的对象,
- vue2.XX 提示[Vue warn]: Error in render: "TypeError: Cannot read property 'img' of undefined"
item 是向后台请求的一条数据,里面包含img,但是却提示img未定义 父组件向子组件传递数据时, 子组件 具体代码: <img :src="item.img" /> ...
- [Vue warn]: Error in render: "TypeError: Cannot read property 'matched' of undefined" found in <App> at src/App.vue
当用Vue模块化开发时,输入 http://localhost:8080 页面没有显示,首先按F12,检查是否有如下错误 话不多说,直接看下面: 解决方法1 如果是上面出的问题,以后就要注意了哦, ...
- Error in render: "TypeError: Cannot read property 'url_img' of undefined"
如果我们 vue 组件中 template 里面添加了下标(靠数组索引得到的值),就会报索引为 undefined 解决方法: 在我们使用下标时,要在父组件上做条件判断,如果这个下标存在,然后就显示里 ...
- Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')
Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol') 报错信 ...
- vue运行报错error:Cannot assign to read only property 'exports' of object '#<Object>'
用weex做项目的时候,npm start 之后一直报错error:Cannot assign to read only property 'exports' of object '#<Obje ...
- vue报错-Error: Cannot find module '@babel/core'
vue之webpack实战的时候遇到报错,Error: Cannot find module '@babel/core' 这报错,我百度了很久,后来发现报错里面有提示,发现是我的 babel-load ...
随机推荐
- JVM难学?那是因为你没认真看完这篇文章
一:虚拟机内存图解 JAVA程序运行与虚拟机之上,运行时需要内存空间.虚拟机执行JAVA程序的过程中会把它管理的内存划分为不同的数据区域方便管理. 虚拟机管理内存数据区域划分如下图: 数据区域分类: ...
- java之equals 与 == 的区别
== : 1.本质:比较的的是地址,栈内存中存放的对象的内存地址. 2.判断引用所指的对象是否是同一个. 3.两边的操作数必须是同一类型的(可父子类)才能编译通过. 4.值类型(int,char,lo ...
- 一文读懂HTTP/2及HTTP/3特性
摘要: 学习 HTTP/2 与 HTTP/3. 前言 HTTP/2 相比于 HTTP/1,可以说是大幅度提高了网页的性能,只需要升级到该协议就可以减少很多之前需要做的性能优化工作,当然兼容问题以及如何 ...
- Laravel5中通过SimpleQrCode扩展包生成二维码实例
Simple Qrcode是基于强大的Bacon/BaconQrCode库开发的针对Laravel框架的封装版本,用于在Laravel中为生成二维码提供接口. 安装SimpleQrCode扩展包 在项 ...
- node处理表单文件,获取formdata的数据
参考文章:https://blog.csdn.net/a895458278/article/details/48055143# 应用: formidable使用: 原生的node.js在处理客户端以P ...
- js 递归修改json无限级key值
var tree = [ { name: 'node1' }, { name: 'node2', children: [{ name: 'node-2-1' }, { name: 'node2-2' ...
- Dynamics 365-RetrieveDependenciesForDeleteRequest
不少人在使用Dynamics 365的时候,或多或少都会遇到Delete a Component的情况,比如Unregister a Plugin/Workflow. 想象这么一个常见的情形:你定制了 ...
- 使用OCLint和Sonar对iOS代码分析和质量管理
OCLint 是一个强大的静态代码分析工具,可以用来提高代码质量,查找潜在的bug,主要针对c,c++和Objective-c的静态分析. Sonar 是一个用于代码质量管理的开放平台.通过插件机制, ...
- iPad----------教你如何查询ipad型号
1.首先进入苹果官网 找到support https://support.apple.com 2.找到查询ipad型号的地方 点击Check coverage for your produc ...
- uiautomatorviewer 查看元素报错: Error taking device screenshot: null 原因
使用uiautomatorviewer 查看android某些页面元素,出现错误Error obtaining UI hierarchy Reason: Error taking device sc ...