function getPromise(url, method = 'GET', data = {}, header = {}) {
return new Promise((resolve, reject) => {
wx.request({
url: url,
header: header,
success: function (res) {
resolve(res)
}, fail: function (res) {
reject(res)
}, method: method, data: data,
dataType: 'json'
})
})
}如上进行封装;如下进行调用getPromise(_url, 'POST', _data)
.then((res) => {
})如上调用,不过,如果多个请求相互嵌套呢,怎么解决?getPromise(_url, 'POST', _data)
.then((res) => {
getPromise(_url, 'POST', _data)
.then((res) => {
...
})
})
添加回答
举报
0/150
提交
取消