[Vuejs]-Initialize array data from array prop in a Vue component

0👍

If selectedSuppliers is an array of object, then the spread operator only performs a shallow copy of this array. It means that updating any object of suppliers will update the content of selectedSuppliers.

You can take a look at this short post.

0👍

This might work,

props: {
  selectedSuppliers: {
    type: Array,
    required: true
  },
},
data () {
  return {
    selected: this.selectedSuppliers.map(o => Object.assign({}, o)
  }
}

Leave a comment