I've read 4 or 5 similar questions here, but can't get it to work: I have an array of objects called ESBegriffe
data()
return{
ESBegriffe: {
0:{"id":0,"typ": 1,"Kategorie": 1,"Begriff":"foo","Reihenfolge":0},
1:{"id":1,"typ": 1,"Kategorie": 2,"Begriff":"foo","Reihenfolge":1},
2:{"id":2,"typ": 2,"Kategorie": 1,"Begriff":"foo","Reihenfolge":0},
3:{"id":3,"typ": 2,"Kategorie": 2,"Begriff":"foo","Reihenfolge":0},
4:{"id":4,"typ": 2,"Kategorie": 1,"Begriff":"foo","Reihenfolge":1},
}
}
and a method addBegriff to add an object to this array:
methods: {
addBegriff: function(){
var object = {5:{"id": 5,"typ": 2,"Kategorie": 1,"Begriff": "BegriffK12","Reihenfolge":1}};
this.ESBegriffe.push(object);
},
}
activated by a button:
<i @click="addBegriff"> Add(+) </i>
but it doesn't work, on click I get the error
TypeError: "this.ESBegriffe.push is not a function"
What am I doing wrong here?