Blame view

src/store/index.js 500 Bytes
843fce64e   wulunyi   feat(master): 加入 ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  import Vue from 'vue'
  import Vuex from 'vuex'
  
  Vue.use(Vuex)
  
  const modulesFiles = require.context('./modules', true, /\.js$/)
  
  const modules = modulesFiles.keys().reduce((modules, modulePath) => {
    const moduleName = modulePath.replace(/^\.\/(.*)\.\w+$/, '$1')
    const value = modulesFiles(modulePath)
  
    modules[moduleName] = value.default
  
    return modules
  }, {})
  
  const store = new Vuex.Store({
      modules,
      getters: {
          list: state => state.test.list
      }
  })
    
  export default store;