0👍
It seems I found a way to pass models into components. I simply assigned the models
object to state
property of a vuex module. This way I have access to the models in components via this.$store.state.models
. These are changes to the pattern described in my question:
*** store.js ***
import vuexModule from './modules/vuexModule';
import vuexModels from './modules/vuexModels';
export const store = new Vuex.Store({
modules: { vuexModule, models: vuexModels }
});
*** vuexModels.js ***
import { models } from 'pathToModels/models';
const state = models;
export default { state };
It is also important to import store
in the entry file before the App.vue
.
Source:stackexchange.com