axios.post('', { data: params },{ headers: { 'Access-Control-Allow-Origin':'*', //解决cors头问题 'Access-Control-Allow-Credentials':'true', //解决session问题 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' //将表单数据传递转化为form-data类型 }, withCredentials : true }) .then(function (response) { var res = response.data; if(res=="登录成功,3秒后跳转主页") { var noticeId= JSON.parse(window.sessionStorage.getItem('user')); alert(noticeId) alert(response.data); setTimeout(that.LoginSuccess, 3000) }else if(response.data=="用户名不存在,请注册后重新登录") { that.message = response.data } }) .catch(function (error) { alert(error); });
关于axios的post用法
最新推荐文章于 2025-03-09 14:46:09 发布