I've encountered an issue in my VueJS + Quasar project where I'm trying to utilize useQuasar()
in my store file gallery.js
, but it keeps returning undefined.
A similar problem arose when I was attempting to access useRouter()
, however, I managed to find a workaround. There is an export for router
in the
node_modules/quasar/wrappers/index
file, so I utilized that to pass my stores from the main store index.js file:
import { route, store } from 'quasar/wrappers';
import { createPinia } from 'pinia';
import { markRaw } from 'vue';
export default store((/* { ssrContext } */) => {
const pinia = createPinia();
pinia.use(({ store }) => {
store.router = markRaw(route);
});
return pinia;
})
Here is a snippet from my sample store file:
import { defineStore } from 'pinia';
import { useQuasar } from "quasar";
export const useGalleryStore = defineStore('gallery', {
actions: {
test_function() {
const $q = useQuasar();
console.log($q); // undefined
}
}
})
I also tried looking for the quasar
export in the
node_modules/quasar/wrappers/index
file, but it seems to be missing. Thus, I'm unable to use this.$q
, $q
, or useQuasar()
in my store file.
Specifically, I require $q.notify()
, $q.platform
, and $q.screen
in my implementations.
Is there a method to incorporate them within the store file?