axios模拟表单提交
url: 'url地址',
method: 'post',
data: {
username: username,
password: password
},
// 提交前更改格式
transformRequest: [function(data) {
let ret = ''
for (const it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}],
// 携带表单请求头
headers: {
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
}