을 정의되지 나는 다음과 같은 코드를 작성하고 뷰는 불평 : VueJS2 속성이
은 [뷰는 경고] : 건물 또는 방법 "사건"은 인스턴스에서 정의되어 있지만 렌더링하는 동안 참조되지 않습니다. 데이터 옵션에 반응성 데이터 속성을 선언해야합니다.
인시던트에 액세스 할 수없는 이유는 무엇입니까? 외부로부터 할당 될 수있다 소품, 구성 요소에 대한 props
키를 사용하여 정의되는 동안
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);
});
}
}
})
문제를 보여주는 [fiddle] (https://jsfiddle.net/er3tjyh0/)을 만들 수 있습니까? – Saurabh