I have an object with the following structure:
obj: {
1: {
'a': [ [] ],
'b': [ [] ]
}
}
Now, I am attempting to append 'c' => [ [] ]
to this object in a watcher.
My first attempt was using
this.obj[1]['c'] = [ [] ]
, however, it did not watch changes on the props of the child component when done this way. I suspect that I need to use$set
.Next, I tried
- while this successfully watched the changes, it unfortunately removed the 'a' and 'b' properties entirely.this.$set(this.obj, 1, { ['c']: [ [] ] })
Lastly, I attempted
- this appeared to change the object but still didn't trigger prop watches.this.$set(this.obj[1], ['c'], [ [] ]);
What is the correct way to use $set?