小程序
小游戏
企业微信
微信支付
扫描小程序码分享
如果一个页面有三个异步,三个异步不互相阻塞, 并且知道 全部请求完的时候,该怎么处理;
正常是怎么处理的
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
async
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
三个回调套嵌呗。
const request = (url, data, method) => {
return new Promise((resolve, reject) => {
wx.request({
url,
data,
method,
success(res=>{
resolve(res)
}),
fail(()=> {
reject()
})
}
const a = () => {
return request(xx, xx, xx).then(res=>{
// your code here
const b = () => {
const c = () => {
const demo = () => {
Promise.all([a,b,c]).then(()=> {
}).catch(err => {
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
async
三个回调套嵌呗。
const request = (url, data, method) => {
return new Promise((resolve, reject) => {
wx.request({
url,
data,
method,
success(res=>{
resolve(res)
}),
fail(()=> {
reject()
})
})
})
}
const a = () => {
return request(xx, xx, xx).then(res=>{
// your code here
})
}
const b = () => {
return request(xx, xx, xx).then(res=>{
// your code here
})
}
const c = () => {
return request(xx, xx, xx).then(res=>{
// your code here
})
}
const demo = () => {
Promise.all([a,b,c]).then(()=> {
// your code here
}).catch(err => {
// your code here
})
}
title:''})
}