[Vuejs]-How can my partials access the main data object in Vue?

0👍

There is no simple way to just use variables from another file. It’s Vue, so you need to read how to connect Components. Using Properties can help you as well.

Keep in mind that all of this has nothing to do with how you separate your code into files. It’s a whole ecosystem and you need to connect stuff in Vue, not in JS files 🙂

0👍

When your app will grow and you will certainly get multiple "co-dependent" values etc. you will probably get to the point that such methods will not be very "readable".

I suggest you look into "state management" – in the example of Vue maybe Vuex (https://vuex.vuejs.org/en/intro.html) as it will soon be required in medium to large size of all your apps.

Otherwise you can use "event bus" communication (https://v2.vuejs.org/v2/guide/components.html#Non-Parent-Child-Communication). But you will probably "outgrow" it pretty soon…

Hope it helps…

Leave a comment