站长资源网络编程

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

整理:jimmy2026/7/30浏览2
简介设置 axios.defaults.withCredentials = true 即可示例代码:axios.defaults.withCredentials = true;var param = new URLSearchParams();param.append("vCode",vcode);a

设置 axios.defaults.withCredentials = true 即可

示例代码:

 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);
  });

以上这篇基于axios 解决跨域cookie丢失的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。