通过全局方法 Vue.use() 使用插件
1.global.js
import api from './index'
export default {
install (Vue) {
Vue.prototype.$http = api
}
}
2.在main.js中引入
import globalApi from './api/global'
Vue.use(globalApi)
3.在任意组件中使用
this.$http.xxx()
通过全局方法 Vue.use() 使用插件
1.global.js
import api from './index'
export default {
install (Vue) {
Vue.prototype.$http = api
}
}
2.在main.js中引入
import globalApi from './api/global'
Vue.use(globalApi)
3.在任意组件中使用
this.$http.xxx()