axios post请求转formdata

axios post请求转formdata

axios({ url: Config.url.wechat_url + '/member/register', method: 'post', data: { password: self.password, code: self.validCode, phone: self.phoneNumber }, transformRequest: [function (data) { var ret = ''; for (var it in data) { ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&' } return ret }], headers: {'Content-Type': 'application/x-www-form-urlencoded'} }).then(function (res) { if (res.data.code === 200) { self.$toast ({message:'恭喜您注册成功', duration: 1500}); localStorage.setItem("phoneNumber", res.data.data.phoneNumber); localStorage.setItem("password", res.data.data.password); setTimeout(function () { window.location.href = '/user/login'; },1500) }else{ self.$toast ({message:'哎呀,请求出错啦', duration: 1500}) } }).catch(function (error) {self.$toast ({message:'网络出了问题', duration: 1500});})

猜你喜欢

转载自www.cnblogs.com/lilyhj/p/9050587.html