摘要: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;
批改老师:西门大官人批改时间:2019-02-24 09:25:56
老师总结:注意一下,在js中对变量是否定义的判断用undefined,不能加引号。