- After the basic post request, you see Request is transmitted in the form of Payload parameters, not form-data format. At this point add the head headers.
this.axios.post('url',{
userCardId: promptValue
}).then(res => {
})
2. Add headers: { 'Content-Type': 'application / x-www-form-urlencoded'}; the following results, Form Data passed an object.
this.axios({
method:'post',
url:'url',
data:{userCardId:promptValue},
headers:{'Content-Type':'application/x-www-form-urlencoded'},
}).then(res =>{
})
3. Continue adding transformRequest part, do data conversion. At this time, the rear end can receive the data.
this.axios({
method:'post',
url:'url',
data:{userCardId:promptValue},
headers:{'Content-Type':'application/x-www-form-urlencoded'},
transformRequest:[function (data) {
let ret = ''
for (let it in data) {
ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
}
return ret
}],
}).then(res =>{
})
https://github.com/Gesj-yean/vue-demo-collection documented use more outstanding plug-ins. Students have time to look at my top blog can thank you very much.