Vue.use

不管是对象还是函数install 是Vue.use()必须要有的方法 否则无法使用(Vue.use(MintUI))但axios 不需要Vue.use(axios) 可以直接使用 因为axios没有install

Vue.use() 为全局注册一个组件 典型案例Vue.use(Router) this.$router

install 方法 也就是说,如果传入的是对象,那就调用插件的install方法并通过apply()方法将install方法改变this的指向为plugin。插件类型为function时,插件运行的上下文this指向null(严格模式下;非严格模式下指向window)将Vue作为参数传入、在vue文件用this调用

还可以添加到defineProperties

在main.js 注册 Vue.use(Http)

原文地址:https://www.cnblogs.com/QQPrincekin/p/11003444.html