‘Content-Type’: ‘application/x-www-form-urlencoded’ 请求
1. 使用{key:value}:方式
this.$axios.post('url/XXXX', JSON.stringify(params), { headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }})
.then(res => {
console.log(res)
})
.catch(() => {})
2. 使用key: value方式
安装 yarn add qs
import qs from 'qs'
this.$axios.post('url/XXXX', qs.stringify(params), { headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }})
.then(res => {
console.log(res)
})
.catch(() => {})
注:参考连接
https://blog.csdn.net/hbiao68/article/details/106004100