Axios的源码对get请求的content-type处理过了
// Add headers to the request
if ('setRequestHeader' in request) {
utils.forEach(requestHeaders, function setRequestHeader(val, key) {
if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
// Remove Content-Type if data is undefined
delete requestHeaders[key];
} else {
// Otherwise add header to the request
request.setRequestHeader(key, val);
}
});
}
所以需要在拦截器里处理一下get请求
Axios.defaults.headers.get['content-type'] = 'application/json;charset=UTF-8'
Axios.interceptors.request.use(
config => {
Toast.loading({
mask: true,
duration: 0
})
let token = getCookie('usertoken'