Files
wx_epaper_lite/utils/promisify.js
风不出来 bdfae48fc2 000
2024-06-04 19:59:44 +08:00

40 lines
434 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* wxPromisify
* @fn 传入的函数如wx.request、wx.download
*/
function wxPromisify(fn) {
return function (obj = {}) {
return new Promise((resolve, reject) => {
obj.success = function (res) {
resolve(res)
}
obj.fail = function (res) {
reject(res)
}
fn(obj)//执行函数obj为传入函数的参数
})
}
}
module.exports = {
wxPromisify,
}