原因:报这个错误的原因是v-for 循环时还没有拿到data,导致循环对象时出错。使用loadtime属性(manual/onready/auto)延迟加载也解决不了,着实非常烦人;有时不但控制台报错,前台页面直接渲染不出来,但是能打印data的内容,也是这个原因!
有时报这个错误:Uncaught (in promise)TypeError: Cannot read property ‘id’ of undefined
有时报这个:Uncaught TypeError: Cannot read property ‘parentNode’ of null
解决办法:经过本人多次测试发现,在v-for循环数据前加这个data是否已拿到的判断:“<view v-else-if=”data”>”就可以完美不报错了!~
<view v-if="error">{{error.message}}</view>
<view v-else-if="data">// 需要加这个data是否已拿到的判断
<view v-for="(item,index) in data" :key="index">
{{item.title}}
</view>
</view>