You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importVuefrom'vue'importVuexfrom'vuex'importgettersfrom'./getters'importactionsfrom'./actions.js'importmutationsfrom'./mutations.js'Vue.use(Vuex)// https://webpack.js.org/guides/dependency-management/#requirecontextconstmodulesFiles=require.context('./modules',true,/\.js$/)// you do not need `import app from './modules/app'`// it will auto require all vuex module from modules fileconstmodules=modulesFiles.keys().reduce((modules,modulePath)=>{// set './loading.js' => 'loading'// set './work' => 'work'constmoduleName=modulePath.replace(/^\.\/(.*)\.\w+$/,'$1')constvalue=modulesFiles(modulePath)modules[moduleName]=value.defaultreturnmodules},{})conststore=newVuex.Store({
modules,
getters,
actions,
mutations
})exportdefaultstore
The text was updated successfully, but these errors were encountered:
ly525
changed the title
便利 vuex-store/modules 下的所有文件,自动加载所有的 vuex 的module
遍历 vuex-store/modules 下的所有文件,自动加载所有的 vuex 的module
Sep 17, 2019
The text was updated successfully, but these errors were encountered: