abstract:var requestUrl = "http://tp51.io/api.php/";function post(url, data, fun, that) {if (url == 'undefined') {return false;}var postUrl = requestUrl + url;wx.request({url: postUrl,data: d
var requestUrl = "http://tp51.io/api.php/";
function post(url, data, fun, that) {
if (url == 'undefined') {
return false;
}
var postUrl = requestUrl + url;
wx.request({
url: postUrl,
data: data,
method: "POST",
dataType: "json",
header: {
'content-type': 'application/json'
},
success: function (res) {
that[fun](res.data.result);
},
fail: function (res) {
console.log('请求失败,请重试');
return {};
}
})
}
module.exports.post=post;
Correcting teacher:西门大官人Correction time:2019-02-24 09:25:56
Teacher's summary:注意一下,在js中对变量是否定义的判断用undefined,不能加引号。