微信小程序 wx.request

一:问题

微信小程序 post请求时,服务器后台接受不到data里面的数据的bug。

二:解决办法

wx.request({
        url: 'http://xxxxxxxxx/Create',
        method: 'POST',
        data: {
          "userid": userid,
          "way": way,
          "specificWay": specificWay,
          "money": money,
          "dateTime": e.detail.value.date + ' ' + e.detail.value.time + ':' + second,
          "notes": e.detail.value.notes,
        },
        header: {
          "content-type": "application/x-www-form-urlencoded"
        },
        success: function (res) {
          console.log(res.data);
        },
        fail: function (res) {
          console.log(res);
        }
      })

在header里面添加一行代码:

 header:{
          "content-type": "application/x-www-form-urlencoded"
        },

 

posted @ 2018-03-06 12:21  5只猫  阅读(243)  评论(0编辑  收藏  举报