import a from './a' import b from './b' let components = { a, b } const installBase = { install (Vue) { Object.keys(components).map(key => Vue.component(key, components[key])) } }
main.js
import Vue from 'vue' import base from './base.js' Vue.use(base) new Vue({ ... })