[Vuejs]-Unshifting vs pushing on a v-for array

0👍

It’s all because of how vuejs track/observe object to be able to react to a change.

I would suggest to use the following syntax when working

  • with array
  
  addItem (item) {
    this.items = [...this.items, item]

  • with object
  
  updateItem (item) {
    this.item = Object.assign({}, this.item, item)
  }

Leave a comment