当前位置:网站首页>js promise.all
js promise.all
2022-07-02 06:41:00 【大鸡腿最好吃】
let d= promise.all([a,b,c])
接受一个promise数组,只有数组里面的promise全部成功才返回成功,要不就失败
只有a、b、c的状态都变成fulfilled,d的状态才会变成fulfilled,此时a、b、c的返回值组成一个数组,传递给d的回调函数。
只要a、b、c之中有一个被rejected,d的状态就变成rejected,此时第一个被reject的实例的返回值,会传递给p的回调函数。
面试题
函数c在函数a和b执行完后才执行
就使用promise.all
let a=function(){
console.log('a')
}
let b=function(){
console.log('b')
}
let p1 = new Promise((resolve, reject) => {
a()
resolve('成功了')
})
let p2 = new Promise((resolve, reject) => {
b()
resolve('success')
})
let c=function(){
console.log('c')
}
Promise.all([p1, p2]).then((result) => {
c()
})
边栏推荐
- [unreal] key to open the door blueprint notes
- Nonlinear optimization: steepest descent method, Newton method, Gauss Newton method, Levenberg Marquardt method
- Network communication learning
- VLAN experiment
- Ue5 - ai Pursuit (Blueprint, Behavior tree)
- SQOOP 1.4.6 INSTALL
- allure--常用配置项
- MongoDB-快速上手MongoDB命令行的一些简单操作
- [pit avoidance guide] pit encountered using ugui: the text component cannot indent the first line by two spaces
- [ue5] two implementation methods of AI random roaming blueprint (role blueprint and behavior tree)
猜你喜欢

pytest--之测试报告allure配置

【JetBrain Rider】构建项目出现异常:未找到导入的项目“D:\VisualStudio2017\IDE\MSBuild\15.0\Bin\Roslyn\Microsoft.CSh

Notes de base sur les plans illusoires d'IA (triés en 10 000 mots)
![[illusory] automatic door blueprint notes](/img/7a/14a66e5b623c7740dc91a15a328b10.png)
[illusory] automatic door blueprint notes

Sum the two numbers to find the target value

ue虚幻引擎程序化植物生成器设置——如何快速生成大片森林
![[ue5] blueprint making simple mine tutorial](/img/87/d0bec747a6b6276d63a315f88745ec.png)
[ue5] blueprint making simple mine tutorial

Delivery mode design of Spartacus UI of SAP e-commerce cloud

Blender模型导入ue、碰撞设置

两数之和,求目标值
随机推荐
【虚幻4】从U3D到UE4的转型之路
Ctrip starts mixed office. How can small and medium-sized enterprises achieve mixed office?
Ue5 - ai Pursuit (Blueprint, Behavior tree)
[200 Shengxin literatures] 95 multiomics exploration TNBC
Webui automated learning
使用Windbg静态分析dump文件(实战经验总结)
SQOOP 1.4.6 INSTALL
Blender石头雕刻
Zlib download and use
[visual studio] every time you open a script of unity3d, a new vs2017 will be automatically reopened
UE4 night lighting notes
Nonlinear optimization: establishment of slam model
【虚幻4】UMG组件的简介与使用(更新中...)
Applet development summary
[MySQL] an exception occurs when connecting to MySQL: connection must be valid and open
高考的意义是什么
【JetBrain Rider】构建项目出现异常:未找到导入的项目“D:\VisualStudio2017\IDE\MSBuild\15.0\Bin\Roslyn\Microsoft.CSh
Importing tables from sqoop
flume 190 INSTALL
How to achieve the top progress bar effect in background management projects