我正在将 jquery ajax 更改为 axios,但我没有跨域使用 axios:
axios.get(myurl, {
headers: { 'crossDomain': true },
}).then(res => {
console.log(res);
}).catch(error => {
console.log('erro', error);
})
我的 jquery 代码正在运行:
$.ajax({
type: 'GET',
crossDomain: true,
url:myurl,
success: (res) => {},
error: (fail) => {}
})
错误:预检响应中的 Access-Control-Allow-Headers 不允许请求 header 字段 crossDomain。
谁能帮我吗?
最佳答案
“crossDomain”不必位于 header 中
axios.get(myurl, {
crossDomain: true
}).then(res => {
console.log(res);
}).catch(error => {
console.log('error', error);
})
问候
关于ajax - axios跨域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42422494/