1.我在main.js中設置了axios.defaults.withCredentials=true
axios.defaults.crossDomain=true
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'在其他組件用的時候一旦帶參數例如:self.axios.post('http://pj.dianmila.com/supersolid/supersolid_api.php?a=list',{offset:self.swiperlen},{headers: {'Content-Type': 'application/x-www-form-urlencoded'}}).then(function(res) { var datajson = res.data;..................
}
}
}).catch(function (error) {
alert('未能與服務器連接,請稍后嘗試')
console.log(error);
});不加后面的headers的設置就不能跨域了為什么求教2.當我設置了headers之后傳過去的參數是{'offset':5}這種形式,我想要像ajax那樣直接offset:5,不包含在對象里面,如何實現,要加什么配置選項題目描述
axios跨域問題
MMTTMM
2018-09-23 16:24:02