I have a vuex file with a growing mass of mutators, but I\'m not sure of the correct way of splitting it out into different files.
Because I have:
cons
This is another option for splitting your store and have diferent modules, this is already tested.
structure
└── src
├── assets
├── components
└── store
└─ modules
└─ module1
├── state.js
├── actions.js
├── mutations.js
├── getters.js
└── index.js
└─ module2
├── state.js
├── actions.js
├── mutations.js
├── getters.js
└── index.js
└─ index.js
store/index.js
import Vuex from "vuex";
import thisismodule1 from "./modules/module1";
import thisismodule2 from "./modules/module2";
const createStore = () => {
return new Vuex.Store({
modules: {
module1: thisismodule1,
module2: thisismodule2
}
});
};
export default createStore;
store/modules/module1/index.js
import actions from './actions';
import getters from './getters';
import mutations from './mutations';
import state from './state';
export default {
state,
actions,
mutations,
getters
}
store/modules/module2/index.js
import actions from './actions';
import getters from './getters';
import mutations from './mutations';
import state from './state';
export default {
state,
actions,
mutations,
getters
}
Tipp: Don't forget to import your store to your main.js