
vue axios请求设置content-type无效
vue-admin-template开发中在request请求中设置了Content-type,但是在在浏览器中查看请求主体并没有Content-typeservice.interceptors.request.use(config => {if (store.getters.token) {config.headers['X-Token'] = getToken();}config.hea
·
vue-admin-template开发中在request请求中设置了Content-type,但是在在浏览器中查看请求主体并没有Content-type
service.interceptors.request.use(
config => {
if (store.getters.token) {
config.headers['X-Token'] = getToken();
}
config.headers["Content-type"] = "application/x-www-form-urlencoded"
return config
},
error => {
return Promise.reject(error)
}
)

在node_modules文件夹找到axios文件夹
找到xhr.js文件

里面有这样一段
注释掉里面的 if 判断

最后重启项目再看

更多推荐



所有评论(0)