axios跨域Access to XMLHttpRequest
后台设置:
header("Access-Control-Allow-Origin: *");
不起作用.
axios设置请求头headers.
'Content-Type' : 'multipart/form-data'
'Content-Type' : 'application/x-www-form-urlencoded'
const url = "http://www.xxx.com"; const data ={ name: "Jake Taper", email: "taperjake@gmail.com" }; const config = { headers:{ 'Content-Type' : 'multipart/form-data' } }; axios.post(url, data, config) .then(res => console.log(res)) .catch(err => console.log(err))
或
axios({ url: 'http://www.abc.com', method: 'POST', params: { XXXX: 'XXXXXX' }, headers:{
'Content-Type' : 'multipart/form-data',
},
data: { name: 'zhangsan', } }).then((res) => { console.log('数据:', res); })

浙公网安备 33010602011771号