咱們寫好了組件,接下去確定還要引入和使用。可是你寫的組件一旦多起來,在每個個地方都須要去引用是一件很麻煩的事情,因此咱們將一次性全局引入:
important componentA from './componentA important componentB from './componentB important Vue from 'vue const components = [componentA, componentB] const install = function (value, opts = {}){ components.map(component => { Vue.component(component.name, component) }) } export defau;t install
import components from './components.js' Vue.use(components)