经过两个星期的研究,对小程序已经有了一定的理解和运用.目前小程序的本身的不足和 bug 还是很多,下面列举一个我遇到的坑:

      1. wx.request这个网络的 API 是用的很广的一个,不过在发送数据的时候,可能会出现服务器500的现象,而服务器确实没有问题,可能形成的原因如下:

       url,method,header,data 的顺序要保证准确, content-type 需要小写不能写成 Content-Type(目前微信小程序是区分大小写的),使用 post 需要配置 header 中的不同参数"content-type": "application/x-www-form-urlencoded"针对 json的 post 

    通过的正确实例:

      wx.request({      url: "http://127.0.0.1:8000/xxxx",      method: "POST",      header: {        "content-type": "application/x-www-form-urlencoded"      },      data: {        name:name,        address: address,        numberid: numberid,        email: email,      },      success: function (res) {        console.info(res);      }    });

TAG标签: 微信小程序500报错

http://www.xiaochengxub.com/read-103000.html