0

I am using the latest version of Vue.js and I need to use a global object for sharing state in Single Page Vue components. What I'm trying to do is storing the state from a websocket connection in a global object so I can perform actions in Vue.

The problem is that the object is always undefined in Vue.js, but I can clearly see in the browser that the object is populated and have the correct data.

It works using Obj.$set() and adding every single property, but I don't want to do that since I don't know all properties beforehand.

rac
  • 263
  • 2
  • 7
  • 13
  • http://stackoverflow.com/a/43193455/7636961 – Egor Stambakio May 02 '17 at 09:52
  • Consider using VUEX (https://vuex.vuejs.org/en/intro.html). This is what vuejs recommends for a shared centalized state – Vamsi Krishna May 02 '17 at 10:29
  • @wostex inappropriate place to ask but you are the only one I keep seeing answering vuejs related questions...can you help me out with this(http://stackoverflow.com/q/43735371/7814783) – Vamsi Krishna May 02 '17 at 10:37
  • I even tried to move out the shared object to an external script, it is still undefined in vue components. The link above does not work – rac May 02 '17 at 12:53
  • 1
    Possible duplicate of [Global data with VueJs 2](http://stackoverflow.com/questions/43193409/global-data-with-vuejs-2) – Bert May 02 '17 at 15:51

0 Answers0