1. Function: Vue provides a static method for registering plug-ins with Vue (enhancing Vue’s functionality)

Document address: cn.vuejs.org/v2/api/#Vue…

2. Format: vue.use (obj)

3. Specification:

Use can receive an object. Vue. Use (obj) object needs to provide an install function. When VueCopy the code

4. Install parameters and execution

const MyPlugin = {
	install(obj) {
    console.log('install..... ', obj)
  }
}
Vue.use(MyPlugin)
Copy the code

5. Define global components

importcomponentfrom 'path'
export default {
  install(Vue) {
    Vue.component('Component name 1', component object1)
    Vue.component('Component name 2', component object2)... }} Use: register the plug-in in main.jsimportThe name of the registered componentfrom 'path'Vue.use(Registered component name)Copy the code