【发布时间】:2018-07-30 05:18:36
【问题描述】:
我无法使用索引访问数组中的数据。
我的模板中有以下代码。
<a href="#" class="...">{{ fixture.flatOdds.data[0].market_id }}</a>
然后抛出:
TypeError: fixture.flatOdds.data[0] is undefined
但fixture.flatOdds.data[0] 已定义。当我像这样打印出 fixture.flatOdds.data[0] 时:
<a href="#" class="...">{{ fixture.flatOdds.data[0] }}</a>
它可以很好地打印出对象。回应,
{ "bookmaker_id": 2, "bookmaker_event_id": null, "market_id": 1, "odds": [ { "label": "1", "value": 3, "winning": null, "handicap": null, "total": null, "last_update": { "date": "2018-07-29 08:15:53.000000", "timezone_type": 3, "timezone": "UTC" } }, { "label": "X", "value": 3.2, "winning": null, "handicap": null, "total": null, "last_update": { "date": "2018-07-29 08:15:53.000000", "timezone_type": 3, "timezone": "UTC" } }, { "label": "2", "value": 2.38, "winning": null, "handicap": null, "total": null, "last_update": { "date": "2018-07-29 08:15:53.000000", "timezone_type": 3, "timezone": "UTC" } } ] }
我做错了什么?
注意:我正在使用 axios 从 API 加载数据。
【问题讨论】:
标签: javascript vue.js vuejs2