请问如何将service.js回调函数取得的结果抛给调用者home.js?
来源:5-5 告别回调地狱——async、await与同步、异步编程(上)
Zz皓
2022-07-21
除了使用回调函数的方法,还有其他办法吗
getServiceList(page, count, callback, category_id=null, type=null) {
Http.request({
url: 'v1/service/list',
data: {
page,
count
}
}, (res)=>{
console.log('service.js:')
console.log(res)
callback(res)
})
}
_getServiceList() {
service.getServiceList(1,10,(res)=>{
console.log('home.js:')
console.log(res)
})
}
写回答
1回答
-
还有课程里讲的 async/await语法糖的方式。
012022-07-22
相似问题