Vue: how to turn an object to reactive?

Created on 12 Apr 2016  路  2Comments  路  Source: vuejs/vue

is there a good way to turn an object to be reactive after the vue instance was inited.

I have to call Vue.set recursively to turn an object to be reactive, is there an confortable way?
thx

Most helpful comment

Hi there, please make sure to read the Issue Reporting Guidelines before opening new issues. The issue list only accepts bug reports and feature requests. Questions should be posted to the Gitter chat room, forum or StackOverflow. Thanks.


vm.$set(key, object) -> object is now reactive

All 2 comments

Hi there, please make sure to read the Issue Reporting Guidelines before opening new issues. The issue list only accepts bug reports and feature requests. Questions should be posted to the Gitter chat room, forum or StackOverflow. Thanks.


vm.$set(key, object) -> object is now reactive

The above did not work for me. however, this one did:

var sharedObject = {/*...*/};
var tmpVm = new Vue({ data : { sharedObject } });
sharedObject = tmpVm.sharedObject;

and in my case, I was running it in a constructor of a class, so:

constructor() {
  new Vue({ data: { reactive: this } });
}
Was this page helpful?
0 / 5 - 0 ratings