post 时Content-Type

2019-08-26  本文已影响0人  kelly_0416

使用axios时,post的data参数

1.application/x-www-form-urlencoded
data类型-表单(axios默认值)
data需要qs.stringify

return axios.post(URL, qs.stringify(data));
application:x-www-form-urlencoded.png

2.application/json;charset=UTF-8
json类型

return axios.post(URL, data, { header: {
        'Content-Type': 'application/json;charset=UTF-8'
    }} );
//或者
return axios.post(URL, data );
application:json;charset=UTF-8.png

form.后端用参数接数据,json后端用body接数据

上一篇下一篇

猜你喜欢

热点阅读