微信小程序封装请求接口

时间:2019-09-07 01:34:29   收藏:0   阅读:142
var rootDocment = ‘https://123.com‘;//你的域名
function postData(url, data, cb) {

wx.request({

      url: rootDocment + url,
      data: data,
      method: ‘post‘,
      success: function (res) {
        return typeof cb == "function" && cb(res)
      },
      fail: function () {
        return typeof cb == "function" && cb(false)
      }
    })
}
技术图片

 

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!