if (!(window.Vue && window.Vue.prototype.$request)) { // 添加请求拦截器 window.axios && window.axios.interceptors.request.use(config => { const { data } = config; if (data) { let params = ''; for (const key in data) { params = params.indexOf('?') === -1 ? `${params}?${key}=${data[key]}` : `${params}&${key}=${data[key]}`; } config.url += params; } // GET 参数拼接到 url后面 return config; }, error => { return Promise.reject(error); }); // 添加响应拦截器 window.axios && window.axios.interceptors.response.use(response => { return response.data; }, error => { return Promise.reject(error); }); }