小程序request请求 POST请求参数传递不到后台

需要在微信请求 wx.request 改变默认 header 配置为如下

wx.request({
  url: 'test.php', //仅为示例,并非真实的接口地址
  data: {
     x: '' ,
     y: ''
  },
  header: {
    'content-type': 'application/x-www-form-urlencoded' // 改变默认值为这个配置
  },
  dataType: 'json', // 添加这个配置
  success: function(res) {
    console.log(res.data)
  }
})

转载: https://www.cnblogs.com/zhourongcode/p/9519777.html

 

posted @ 2019-06-06 10:31  诚享人生  阅读(363)  评论(0)    收藏  举报