index.js 452 B

123456789101112131415161718
  1. import Vue from "vue";
  2. import Vuex from "vuex";
  3. Vue.use(Vuex);
  4. const files = require.context("./modules", false, /\.js$/);
  5. let modules = {
  6. state: {},
  7. mutations: {},
  8. actions: {}
  9. };
  10. files.keys().forEach((key) => {
  11. Object.assign(modules.state, files(key)["state"]);
  12. Object.assign(modules.mutations, files(key)["mutations"]);
  13. Object.assign(modules.actions, files(key)["actions"]);
  14. });
  15. const store = new Vuex.Store(modules);
  16. export default store;