其他分享
首页 > 其他分享> > [Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined"

[Vue warn]: Error in render: "TypeError: Cannot read property '0' of undefined"

作者:互联网

分析:
异步请求获得的数据是一个对象,对象中又有数组,直接在子组件中使用数组时需要使用v-if进行判断
数据类型如下:

{"error":0,"data":{"name":"粥品香坊","description":"蜂鸟专送","deliverytime":38,"score":4.2,"serviceScore":4.1,"foodScore":4.3,"supports":[{"type":0,"description":"在线支付满28减5"},{"type":1,"description":"VC无限橙汁全场送"},{"type":2,"description":"优惠卷80抵100"}]}}

文件代码:
在这里插入图片描述
报错信息:
在这里插入图片描述
解决:
添加v-if进行条件判断

<div v-if="seller.supports">支付类型:{{seller.supports[0].description}}</div>

标签:TypeError,undefined,render,type,香坊,数组,专送,supports,description
来源: https://blog.csdn.net/weixin_45034639/article/details/100800789