当前位置:网站首页>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]是否存在,不存在就不显示

边栏推荐
猜你喜欢
随机推荐
stack stack
Day 77
解决npm warn config global `--global`, `--local` are deprecated. use `--location=global` instead.
Unity 数字跳字功能
[Meetup Preview] OpenMLDB+OneFlow: Link feature engineering to model training to accelerate machine learning model development
将UI的点击事件渗透下去
PAT乙级刷题之路
Real-time Feature Computing Platform Architecture Methodology and Practice Based on OpenMLDB
helm安装
Byte (byte) and bit (bit)
Lua中and和or的用法和记忆方法
js learning advanced BOM part (pink teacher notes)
The role of the port
【LeetCode-455】方法饼干
nepctf Nyan Cat 彩虹猫
Compilation exception resolution
Building a data ecology for feature engineering - Embrace the open source ecology, OpenMLDB fully opens up the MLOps ecological tool chain
详解程序执行过程
Unity的程序集Assembly 与 加快代码编译速度
虚拟机更改IP地址









