DEV Community

Discussion on: [VUE] How to access a variable from another instance

Collapse
 
fencina profile image
fencina

Hi there!

You should try using a state pattern (check vuejs doc vuejs.org/v2/guide/state-managemen...)

Basically, you create a data object and allow your instances to "share" it.
Therefore, you can access and mutate this object from those instances, and it behaves in a reactive way.

If your application grow up, you should evaluate using vuex (vuex.vuejs.org/), which helps you with some issues you may find when working with state management, such as painful debugging.

Hope this helps you!