分析:
异步请求获得的数据是一个对象,对象中又有数组,直接在子组件中使用数组时需要使用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>