axios 转换表单形式提交数据 application/x-www-form-urlencoded

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export function post(query) {
return request({
// url: '',

transformRequest:[function(data){
let ret = ''
for(let it in data){
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}],
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
method: 'post',
params: query
})
}
0%