关于微信小程序请求体的问题

2/13/2017来源:iOS开发人气:439

我的程序: wx.request( { //取默认搜索关键词 url: url, data: { action: "EncryController/actionIndex", "perpage": perpage, "pageindex": pageindex }, // header: // { // 'Content-Type': 'application/json' // }, header: { 'Content-Type': 'application/x-www-form-urlencoded' }, dataTpe: "text", method: "POST", timeout: 10000, error: function () { //alert("服务器超时"); }, success: function (data) { console.log("isFresh" + isFresh); if (isFresh) { pageindex = 1; that.setData({ list: data.data.data.resourcesarr, hidden: true, page: 1, hasRefesh: false, }); } else { pageindex = pageindex + 1; console.log("pageindex:" + pageindex); var listadd = that.data.list; var imghiddenarray = that.data.imghiddenarray; for (var i = 0; i < data.data.data.resourcesarr.length; i++) { listadd.push(data.data.data.resourcesarr[i]); } console.log(" that.data.list:" + that.data.list[11].title); that.setData({ list: listadd, hidden: true, page: 1, hasRefesh: false, }); } } }); 若选择post则content-type格式为:’application/x-www-form-urlencoded‘ get则content-type格式为:‘application/json’