通常有两种情况:

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.判断是否存在

<div v-if="poiInfo2.discounts2"><img :src="poiInfo2.discounts2[0].icon_url" >{{poiInfo2.discounts2[0].info}} </div>

vue报错Error in render: "TypeError: Cannot read property '0' of undefined"的更多相关文章

  1. [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 ...

  2. 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' ...

  3. app.js:1274 [Vue warn]: Error in render: "TypeError: Cannot read property 'object_id' of undefined"问题小记

    凌晨遇到一个控制台报错的信息,总是显示有对象中的元素未定义 明明是有把定义对象的值的,后面发现是把没有返回值的函数又赋值一遍给未定义的元素所属的对象,

  4. vue2.XX 提示[Vue warn]: Error in render: "TypeError: Cannot read property 'img' of undefined"

    item 是向后台请求的一条数据,里面包含img,但是却提示img未定义 父组件向子组件传递数据时, 子组件 具体代码: <img :src="item.img" /> ...

  5. [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 如果是上面出的问题,以后就要注意了哦, ...

  6. Error in render: "TypeError: Cannot read property 'url_img' of undefined"

    如果我们 vue 组件中 template 里面添加了下标(靠数组索引得到的值),就会报索引为 undefined 解决方法: 在我们使用下标时,要在父组件上做条件判断,如果这个下标存在,然后就显示里 ...

  7. Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol')

    Vue报错: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'protocol') 报错信 ...

  8. 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 ...

  9. vue报错-Error: Cannot find module '@babel/core'

    vue之webpack实战的时候遇到报错,Error: Cannot find module '@babel/core' 这报错,我百度了很久,后来发现报错里面有提示,发现是我的 babel-load ...

随机推荐

  1. [MySQL] mysql的事务隔离和幻读和死锁问题

    1.系统要通过严格的ACID测试,ACID表示原子性/一致性/隔离性/持久性原子性:一个事务必须被视为一个不可分割的最小工作单元一致性:数据库总是从一个一致性的状态转换到另外一个一致性的状态隔离性:通 ...

  2. Ubuntu16.04 安装ROS及其IDE

    一. ROS的安装 1. 进入ROS官方网站 http://wiki.ros.org/ 2. Install -> ROS Kinetic Kame -> Ubuntu 3. 详情可参考所 ...

  3. Python全栈开发之---assert断言

    一.python assert的作用: 根据Python 官方文档解释(https://docs.python.org/3/reference/simple_stmts.html#assert), & ...

  4. 使用这些 HTTP 头保护 Web 应用

    摘要: 安全是个大学问. 这是关于web安全性系列文章的第 三 篇,其它的可点击以下查看: Web 应用安全性: 浏览器是如何工作的 Web 应用安全性: HTTP简介 目前,浏览器已经实现了大量与安 ...

  5. 使用String. localeCompare比较字符串

    javascript提供stringA.localeCompare(stringB)方法,来判断一个字符串stringB是否排在stringA的前面. 返回值:    如果引用字符存在于比较字符之前则 ...

  6. Vue项目用了脚手架vue-cli3.0,会报错You are using the runtime-only build of Vue where the template compiler is not available.....

    摘自: https://blog.csdn.net/wxl1555/article/details/83187647 报错信息如下图: 报错原因是:vue有两种形式的代码:一种是compiler(模版 ...

  7. 不指定源ip时,系统选择哪个ip作为ping包的源ip?

    问题:当centos 有多个网口,发起ping包时,是根据什么规则来确定是使用哪个源ip? 解答:根据目的ip来确定,迭代可以确定源ip 具体的确定方法是, (1)先根据目的ip来确定使用哪个路由表项 ...

  8. MIUI10系统怎么样刷成开发版获得ROOT权限

    小米的设备不同手机型号正常情况下小米官方论坛都提供两个不同系统,可分为稳定版和开发版,稳定版没有提供root超级权限管理,开发版中就提供了root超级权限,在很多工作的时候我们需要使用的一些功能强大的 ...

  9. Web项目发布后字体文件找不到

    一.问题 ①ASP.NET项目,开发工具Visual Studio ②在IIS上发布之后,网页控制台报错,某某文件找不到,但是在服务器文件夹中看明明有那个文件 二.解决方法 ①>>打开II ...

  10. PJSUA2开发文档--第六章 媒体 Media类

    6. 媒体(Media) 媒体对象是能够产生媒体或接受媒体的对象. Media的重要子类是AudioMedia,它代表音频媒体.PJSUA2支持多种类型的音频媒体对象: 捕获设备的AudioMedia ...