我写了下面的代码和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