基於axios 解決跨域cookie丟失的問題
阿新 • • 發佈:2018-11-11
設定 axios.defaults.withCredentials = true 即可
示例程式碼:
前端精品教程:百度網盤下載
?1 2 3 4 5 6 7 8 9 10 11 |
axios.defaults.withCredentials =
true
;
var
param =
new
URLSearchParams();
param.append(
"vCode"
,vcode);
axios.post( 'http://localhost'
,param)
.then(
function
(res) {
var
rs=res.data;
console.log(rs.data);
})
.
catch
(
function
(err) {
console.log(err);
});
|