VUE_axios使用post请求后端接受不到参数,axios使用application/x-www-form-urlencoded和application/json传递参数的两种方式表现形式
‘Content-Type’: ‘application/json’ 请求
将数据转为 key=value 的形式
import qs from 'qs'
http({
method: 'post',
url: 'http://127.0.0.1:10111/login',
data: qs.stringify(data)
})
‘Content-Type’: ‘application/x-www-form-urlencoded’ 请求
将数据转为 key=value 的形式
import qs from 'qs'
http({
method: 'post',
url: 'http://127.0.0.1:10111/login',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: qs.stringify(data)
})