基于axios 解决跨域cookie丢失的问题

设置 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);
 });
posted @ 2018-10-18 15:11  xiaoyingainiaa  阅读(947)  评论(0)    收藏  举报