Global class or Vuex store ?
-
Hello, I’m quite new to Vue and I’d like to have global functions manipulating color palettes which could be called from evry component to manipulate and storing color parameters.
Excuse my naive question, but should I use Vuex for this ?
I tried during many days to have global functions in a store, without success as they are always undefined…Is there a better way to declare global functions and data in Vue or Quasar ?
Thanks -
manipulating color palettes which could be called from evry component to manipulate and storing color parameters.
This is exactly what Vuex is for: Storing and mutating state that can be shared between components.
I tried during many days to have global functions in a store, without success as they are always undefined…
You have to play by the vuex rules to mutate data with mutations( and optionally actions).
Here are some articles:
https://forum.quasar-framework.org/topic/10/proper-way-of-using-quasar-with-vuex
https://techformist.com/access-vuex-store-quasar/
I recommend these courses if you are new to vue and quasar, helped me a lot:
-
Thanks dobbel, but I already made a complex store with Axios use , in a regular Vue App.
If I post here it’s because I moved to Quasar and I’m unable to make a function call with parameters in the store.
Cf. my other post : https://forum.quasar-framework.org/topic/6927/vuex-getter-undefined/4