'Vue.set() alternative for change the entire object

As in the title, I want to know if there is alternative method for Vue.set() for changing the entire object instead of one property.

Vue.set():

this.$set(this.object, 'price', 420);

What I'm looking for:

this.$something(this.object, { 'price': 420 })

Thanks!



Solution 1:[1]

Try with spread syntax

this.object = {
  ...this.object,
  price: 420,
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tony Yip