【发布时间】:2017-11-12 17:02:00
【问题描述】:
我正在尝试在 Vue.js 中访问以下数据
{"id":1,"name":"Westbrook","created_at":"2017-06-10T16:03:07.336Z","updated_at":"2017-06-10T16:03:07.336Z","stats":[{"id":1,"player_id":1,"points":2558,"assists":840,"rebounds":864,"created_at":"2017-06-10T16:03:07.373Z","updated_at":"2017-06-10T16:03:07.373Z"}]}
self.player = response.name 有效。现在我需要self.point
methods: {
fetchData: function() {
var self = this;
$.get("api/v1/players/1", function(response) {
console.log(response);
self.player = response.name;
self.point = response.stats.points
});
}
}
到目前为止,我已经尝试过response.stats["points"]、response.stats[2]、response.stats[ { points } ]、response.stats[points]
【问题讨论】: