whychw
2020-09-06 544a487012bfd067fd21bc553eabdd8457b33b6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import Vue from 'vue'
import axios from 'axios'
import services from './services'
 
if(process.env.NODE_ENV == 'dev') {
    // 跨域请求
    axios.defaults.baseURL = 'http://localhost:8919/Equip_System/';
}
 
axios.defaults.withCredentials = true;
 
axios.defaults.timeout = 100000;
 
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    // 在发送请求之前做些什么
    return config;
}, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
});
 
// 添加响应拦截器
axios.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    // 对响应错误做点什么
    return Promise.reject(error);
});
 
Vue.prototype.$axios = axios;
 
Vue.prototype.$api = services;