[Vuejs]-How to avoid using Vue.set() within external js class files preserving reactivity for nested object properties?

0๐Ÿ‘

โœ…

Oh! I have messed up with Object.assign(). This is a right using of Object.assign() instead of Vue.set():

var button = {};

button[name] = {
    component,
    options,
};

this.buttons = Object.assign({}, this.buttons, button);

This works fine for me. And documentation is here https://v2.vuejs.org/v2/guide/reactivity.html#For-Objects :

// instead of `Object.assign(this.someObject, { a: 1, b: 2 })`
this.someObject = Object.assign({}, this.someObject, { a: 1, b: 2 })

Leave a comment