Consider below code:
let myData = {
a: 1
}
const app = new Vue({
data: myData
});
As Vue docs says when we try to add a property like below, the new property isn't reactive:
myData.b = 12;
console.log(app.b); // undefined
Vue docs suggests using Vue.set
:
Vue.set(myData, 'b', 12);
console.log(app.b); // still undefined
Vue docs says Vue.set
adds a property to a reactive object!
But I want to add b
to the data's root level. I don't know how to make b
reactive.