我寫了下面的代碼和Vue公司抱怨:VueJS2屬性未定義
[Vue公司提醒]:屬性或方法「事件」未在 實例定義,但期間所參考的渲染。確保在數據選項中聲明反應性數據屬性 。
我不明白爲什麼不能訪問事件?
var app = new Vue({
el: '#app',
data: {
responders: [],
incidents: []
},
mounted: function() {
this.getIncidents();
},
methods: {
getIncidents: function() {
console.log('getIncidents');
var app = this;
this.$http.get('/api/v1/incidents').then(function(response) {
// set data
var incidentsReceived = response.data.map(function (incident) {
return incident;
});
Vue.set(app, 'incidents', incidentsReceived);
})
},
getResponders: function() {
console.log('fetchResponders');
var app = this;
this.$http.get('/api/v1/responders').then(function(response) {
// set data on vm
var respondersReceived = response.data.map(function (responder) {
return responder
});
Vue.set(app, 'responders', respondersReceived);
});
}
}
})
可能創建一個[小提琴](https://jsfiddle.net/er3tjyh0/)它顯示的問題? – Saurabh