微信小程序wx.request POST传递中文时显示乱码处理方法


微信小程序wx.request的两种传输方式,一种是get方法,一种是Post方法,在使用post传输中文参数时,会遇到在后台接收到的是乱码的情况,这里需要把header修改为:

'content-type':'application/x-www-form-urlencoded;charset=utf-8',


wx.request({
      url: config.api.reqSubZhengShu,
      data:
      {
        "zsname": usname,
        "bhao": bhao,
        "imgs": imagelists.join("|"),
        "sessionKey": sessionKey,
        "uid":uid,
        "nickName":"中文测试"
      },
      method:"POST",
      header:
      {
        //'content-type': "application/x-www-form-urlencoded" // 默认值
        'content-type':'application/x-www-form-urlencoded;charset=utf-8',
        //'content-type': 'application/json'
      },


注:本文转载自拾图网[http://www.tshinet.com],转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除。
上一篇 下一篇

分享

最新评论

最新加入