我写了以下代码,Vue抱怨:
[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);
});
}
}
})
答案 0 :(得分:0)
public static void main(String[] args) {
Scanner sathya1 = new Scanner(System.in);
System.out.println("Enter the numbers");
int x = (sathya1.nextInt());
int y = (sathya1.nextInt());
int addition = x+y;
int subtraction = x-y;
int multiplication = x*y;
float division = x/y;
if(sathya1.nextInt(addition){
System.out.println("The number is " +addition);
elseif(sathya1.nextInt(subtraction)){
System.out.println("The number is " +subtraction);
elseif(sathya1.nextInt(multiplication)){
System.out.println("The number is " +multiplication);
elseif(sathya.1nextInt(division)){
System.out.println("The number is " +division);
}
}
}
}
}
用于内部组件数据建模,而props可以在外部分配,使用组件的data
键定义。
换句话说,试试:
props
有关组件属性的完整文档,请参阅official guide。
答案 1 :(得分:0)
编辑:第一次没有很好地阅读代码。验证响应中是否包含数据,如果没有,则不将其设置为事件数组。