1.post、get方法header设置:
post设置header
let formdata = new FormData(); formdata.append("account", this.ruleForm.phone); formdata.append("smscode", this.ruleForm.pass); formdata.append("type", "m"); formdata.append("countryCode", this.formInline.region); let _this = this; request .post("https://passport.artron.net/getpasswd/verify", formdata, { headers: { "X-Requested-With": "XMLHttpRequest" }, }).then((res) => { if (res.data.code == 0) { } else { Message.error(res.data.msg); } }).catch(err=>{ console.log(err); });
get设置header
let {userId,token} = {}; userId = userId?userId:'';token = token?token:'' axios.get(this.getUrl(url), {params:data,headers: {userId,token}})