I create Module in index.ts
import { Store, ActionTree } from 'vuex';
import { getModule } from 'vuex-module-decorators';
import cartModule from '~/store/cart/index';
let cartStore: cartModule;
const initializer = (store: Store<any>): void => {
cartStore = getModule(cartModule, store);
};
export const plugins = [initializer];
export {
cartStore,
}
but when I try call to action in Component
import { cartStore } from '~/store';
@Component
...
onClick(): void {
cartStore.add_item({}).then(() => {});
}
I have error
Uncaught (in promise) Error: ERR_STORE_NOT_PROVIDED: To use getModule(), either the module should be decorated with store in decorator, i.e. @Module({store: store}) or store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)
but if I add in the component
import { cartStore } from '~/store';
import { getModule } from 'vuex-module-decorators';
import cartModule from '~/store/cart/index';
@Component
...
onClick(): void {
cartStore.add_item({}).then(() => {});
}
protected created() {
getModule(cartModule, this.$store);
}
It's work... why, why it's happened?
Same issue here. I did what documenation says:
cartStore = getModule(cartModule, store);
But still getting ERR_STORE_NOT_PROVIDED error. Any suggestion? Is it a bug in vuex-module-decorators?
Same issue here as well #244. I guess it's not suitable yet for production.
Most helpful comment
Same issue here. I did what documenation says:
But still getting ERR_STORE_NOT_PROVIDED error. Any suggestion? Is it a bug in vuex-module-decorators?