2019.1.29(6)
axios封装为$http
创建文件夹plugins,文件http.js
import axios from 'axios'
const MyHttpServer = {}
MyHttpServer.install = (Vue)=>{
axios.defaults.baseURL = '' //全局URL
Vue.prototype.$http = axios
}
export default MyHttpServer
在main.js中
import MyHttpServer from './plugins/http.js'
Vue.use(MyHttpServer)