Commit faad9f72 authored by lipengcheng 's avatar lipengcheng

vuex引入require.context

parent 7529dfc9
......@@ -14,9 +14,7 @@ export default {
return this.$route.meta.layout || 'default-layout'
}
},
async created() {
console.log('this.route:', this.route)
},
async created() {},
methods: {
async request() {
let result = await this.$http.get('/webapi/home/banner?type=1&category=18')
......
......@@ -3,8 +3,7 @@ import layoutA from '@/components/layout/layoutA.vue'
// const install = Vue => {
const requireComponent = require.context('.', true, /\.vue/)
console.log('requireComponent:', requireComponent)
// const requireComponent = require.context('.', true, /\.vue/)
// requireComponent.keys().forEach(filename => {
// // 每个文件的详细信息
// const config = requireComponent(filename)
......
import Vue from 'vue'
import Vuex from 'vuex'
import global from './global'
import moduleA from './modules/moduleA'
import uploader from './modules/uploader'
const requireContext = require.context('.', true, /\.js$/)
let modules = {}
requireContext
.keys()
.filter((path) => path !== './index.js')
.forEach((path) => {
const moduleName = path.match(/.*(\/)(\S*).js/)[2]
if (moduleName === 'index') {
console.error('store/modules下的文件名不能为index')
return
}
const file = requireContext(path)
console.log('file:', file)
modules[moduleName] = file.default || file
})
Vue.use(Vuex)
export default new Vuex.Store({
...global,
modules: {
moduleA,
uploader
}
modules
})
......@@ -37,7 +37,7 @@ module.exports = {
.loader('eslint-loader')
.tap((options) => {
// 保存自动eslint修复
options.fix = false
options.fix = true
return options
})
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment