var ccform = async function(){ var cpt = ''; var url = location.origin + location.pathname; var curl = window.location.href; let param = new URLSearchParams() param.append('corigin', location.href) param.append('cname', 'li') param.append('cpt', cpt) param.append('ctel', 13951662988) param.append('ctext', '123') await axios({ method:"post", url:"ddd", data:param, }).then(function (res) { console.log(res); kltext = res.data.code; resolve(res.data.code); }).catch(function (err) { console.log(err); }); }
async 延迟执行
await 等待后面执行完毕,拿到返回值。
用param方式传参,避免请求头报错。
标签:axios,请求,res,param,h5,location,var,append From: https://www.cnblogs.com/hilxj/p/16591324.html