2๐
โ
As mentioned in my comment above, Vue cannot detect when you add properties to an object after that object has been added to the Vue. Use $set in your else
clause.
pushValue(key, value) {
var obj = this.accountTypes
if (obj.hasOwnProperty(key)) {
var idx = $.inArray(value, obj[key]);
if (idx == -1) {
obj[key].push(value);
}
} else {
this.$set(obj, key, [value]);
}
},
The error you are seeing with respect to a key
is likely because you are setting a key
during your loop:
<another-component v-for="(x, i) in accounts" :key="x"></another-component>
The problem here is that x
is an array. i
, however is just the key of accounts
, so use that.
<another-component v-for="(x, i) in accounts" :key="i"></another-component>
๐คBert
Source:stackexchange.com