In addition to that, for a much more typesafe access, we can use getModule() UsegetModule() to create type-safe accessor import{Module,VuexModule,getModule}from'vuex-module-decor
import { Store } from 'vuex' import { getModule } from 'vuex-module-decorators' import example from '~/store/example' let exampleStore: example function initialiseStores(store: Store<any>): void { exampleStore = getModule(example, store) } export { initialiseStores, exampleStore } ...
import { Store } from 'vuex' import { getModule } from 'vuex-module-decorators' import example from '~/store/example' let exampleStore: example function initialiseStores(store: Store<any>): void { exampleStore = getModule(example, store) } export { initialiseStores, exampleStore }...
import{Store}from'vuex'import{getModule}from'vuex-module-decorators'importexamplefrom'~/store/example'letexampleStore:examplefunctioninitialiseStores(store:Store<any>):void{exampleStore=getModule(example,store)}export{initialiseStores,exampleStore}
import { EndUsersModule } from './end-user-module'; import { createModule } from 'vuex-module-decorators'; const endUsers = getModule(EndUsersModule); describe('...', () => { // ... }); And run my tests, I see the following error message: TypeError: Cannot read property 'gett...
// store/modules/passenger.tsimport{Module,VuexModule,Mutation,Action,getModule,}from'vuex-module-decorators';importstorefrom'@/store';typeUser={username:string;password:string;}// dynamic: true: 动态创建动态模块,即new Vuex.Store({})里面不用注册的.空着就行,// store,当前模块注册到store上.也...
vuex-module-decorators import{Action,getModule,Module,Mutation,VuexModule}from'vuex-module-decorators';importstorefrom'@/store';import{IUserInfo,login,loginOut}from'@/api/user-info';import{CODE_SERVER}from'@/utils/enums';import{getUserInfoBySession,removeUserInfoBySession,setUserInfoBySession}from'@...
{ public session = false //# will be a string public get session2() { return this.session } @Mutation public setSession (session: boolean): void { this.session = session } } const userModule = getModule(User) export default userModule // store/index.ts import { createStore } from '...
getStore(ConfigurationStore).init(); getStore(CustomersStore).init(); then i'm getting 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. ...
import store from '@/store'; import { getModule } from 'vuex-module-decorators'; import Auth from '@/store/modules/auth'; const auth = getModule(Auth, store); auth.decr().then((v: number) => { console.log(v); console.log(auth.getCount); console.log(this.$store.getters['auth/...