当前位置:网站首页>Error in render: “TypeError: Cannot read properties of undefined (reading ‘commentsContent‘)“
Error in render: “TypeError: Cannot read properties of undefined (reading ‘commentsContent‘)“
2022-08-11 05:31:00 【爱吃西瓜爱吃肉】
写项目时发现渲染没问题,但是报出Error in render: “TypeError: Cannot read properties of undefined (reading ‘ipconfig‘)“问题
问题出在这里,经过上网百度是说,在渲染时如果读取该对象的属性时,发现该对象不存在那么就会报错
异步调用显示,先显示初始数据然后再显示带数据的数据,刚开始commentsArr还是一个空数组,渲染完后才异步加载带数据的数据。所以开始直接读取commentArr[0]时的对象并不存在,但是渲染完成后加载有数据的数据后又加载好了,于是可以获取到
解决方法:
添加一个v-if判断,判断commentArr[index]是否存在,不存在就不显示
边栏推荐
猜你喜欢
随机推荐
Tinker's self-introduction
Unity C# 面试题、知识点总结
C语言实现三子棋(代码详解)
Day 69
【无标题】
Unity的程序集Assembly 与 加快代码编译速度
C语言-内存操作函数
【LeetCode-202】快乐数
C# 基础之字典——Dictionary(二)
第六届蓝帽杯 EscapeShellcode
Node stepping on the pit 80 port is occupied
C语言-6月8日-求两个数的最小公倍数和最大公因数;判断一个数是否为完数,且打印出它的因子
Compilation exception resolution
Day 83
【转】Unity C# 关于Attribute的使用(超实用)
C语言-6月10日-my_strcpy函数的编写
The mount command - mounted read-only, solution
Lua 快速入门(三)——表(Table)
127.0.0.1 connection refused
【LeetCode-389】找不同