axios post请求变为options请求的解决方法

全局配置

axios.defaults.headers['Content-Type']='application/x-www-form-urlencoded'

注意:使用全局配置会导致所有请求头的‘Content-Type'均为’application/x-www-form-urlencoded'

局部配置

axios.post(url,{

header:{

'Content-Type':'application/x-www-form-urlencoded'

}

})

猜你喜欢

转载自www.cnblogs.com/kongweijian/p/10845815.html