uniapp的post请求失效问题
header:{
'Content-type':'application/x-www-form-urlencoded'
}
//或者:
header : {
'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
}
最终发送给服务器的数据是 String 类型,如果传入的 data 不是 String 类型,会被转换成 String。转换规则如下:
- 对于
GET
方法,会将数据转换为 query string。例如{ name: 'name', age: 18 }
转换后的结果是name=name&age=18
。 - 对于
POST
方法且header['content-type']
为application/json
的数据,会进行 JSON 序列化。(默认) - 对于
POST
方法且header['content-type']
为application/x-www-form-urlencoded
的数据,会将数据转换为 query string