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

posted on 2021-06-24 10:43  Just丶随心  阅读(1327)  评论(0编辑  收藏  举报

导航