[Vuejs]-Using vm.$set on bi-dimentional array

0👍

You can take a few approaches to deal with this:

  1. You could treat it like an array you want to update, in this case
    you could do something like this: vm.$set(this.puzzleGrid[0], 0, {
    "coordinates": { "x": 3, "y": 0 }, "state": { "free": false,
    "label": 2 } });
    which will replace the entire object from
    this.puzzleGrid[0][0] with { "coordinates": { "x": 3, "y": 0 },
    "state": { "free": false, "label": 2 } }
    .

  2. You could update an object contained in the array directly, doing something like this:
    this.$set(this.puzzleGrid[0][0], 'state', { "free": false, "label":
    4 })
    which will replace the value on state with this: { "free":
    false, "label": 4 }
    on the object contained in this.puzzleGrid[0][0].

  3. Also update property by property on an object of the array:
    this.$set(this.puzzleGrid[0][0]['state'], 'free', false).

Leave a comment