You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
/** * axios配置 */ import Vue from 'vue' import axios from 'axios' import VueAxios from 'vue-axios' import setting from './setting' import cookies from 'vue-cookies'; import { Dialog } from 'vant'; import router from '@/router' Vue.use(VueAxios, axios);
//axios.defaults.baseURL = setting.baseURL;
axios.defaults.baseURL =setting.context_path;
axios.defaults.headers.common[setting.tokenHeaderName] =''; axios.interceptors.request.use((config ) => { var url=config.url; if (url.indexOf("?")!=-1) { let queryString = url.split('?')[1] // code=12313123&a=444
if (queryString) { let query = queryString.split('&') for (let i = 0; i < query.length; i++) { let arr = query[i].split('=') if(arr[0]=="token"){ config.headers[setting.tokenHeaderName] =arr[1]; break; } } } } return config; }, (error) => { return Promise.reject(error); }); /* 响应拦截器 */ axios.interceptors.response.use((res) => { return res; }, (error) => { return Promise.reject(error); });
|