123456789101112131415161718192021222324252627 |
- import Vue from 'vue'
- import Vuex from 'vuex'
- Vue.use(Vuex)
- // https://webpack.js.org/guides/dependency-management/#requirecontext
- const modulesFiles = require.context('./modules', true, /\.js$/)
- // you do not need `import app from './modules/app'`
- // it will auto require all vuex module from modules file
- const modules = modulesFiles.keys().reduce((modules, modulePath) => {
- // set './app.js' => 'app'
- const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
- const value = modulesFiles(modulePath)
- // console.log('----',moduleName,value);
- value.default.namespaced=true;
- modules[moduleName] = value.default
- return modules
- }, {})
- // this.$store.dispatch/commit/getters('baseconfig/getBaseconfig')
- const store = new Vuex.Store({
- modules
- })
- export default store
|