23 lines
659 B
JavaScript
23 lines
659 B
JavaScript
import Vue from 'vue'
|
|
import App from './App.vue'
|
|
|
|
const files = require.context('./plugin', true, /index\.js$/); //批量读取模块文件
|
|
const pluginMain = {}
|
|
const plugin = files.keys().reduce((modules, path) => {
|
|
const name = path.replace(/^\.\/(.*)\.js$/, '$1');
|
|
const module = files(path);
|
|
// console.log(module);
|
|
modules[name] = module.default && module.default(Vue) || null;
|
|
if (modules[name]) {
|
|
pluginMain[modules[name].name] = modules[name].value
|
|
}
|
|
return modules;
|
|
}, {});
|
|
Vue.config.productionTip = false
|
|
// console.log('pluginMain',pluginMain);
|
|
new Vue({
|
|
render: h => h(App),
|
|
// components: { App },
|
|
...pluginMain,
|
|
}).$mount('#app')
|