axios使用form格式data发送post请求
文章目录
axios({
url: '/api/xxxx',
method: 'post',
data:{
test:1111
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
transformRequest(data){
let ret = '';
for (let it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&';
}
return ret;
}
})
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论