当前位置:网站首页>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()
})
边栏推荐
- Transport Optimization abstraction
- Introduction and Principle notes of UE4 material
- Operator exercises
- Project practice, redis cluster technology learning (13)
- Importing tables from sqoop
- Test -- Summary of interview questions
- How to achieve the top progress bar effect in background management projects
- SAP Spartacus express checkout design
- Blender摄像机环绕运动、动画渲染、视频合成
- 【虚幻4】UMG组件的简介与使用(更新中...)
猜你喜欢
【虚幻4】UMG组件的简介与使用(更新中...)
VLAN experiment
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
Ue5 - ai Pursuit (Blueprint, Behavior tree)
Post disaster reconstruction -- Floyd thought
pytest框架实现前后置
Flink submitter
[ue5] blueprint making simple mine tutorial
Message mechanism -- getting to know messages and message queues for the first time
Vscode set JSON file to format automatically after saving
随机推荐
pytest--之测试报告allure配置
[unity3d] cannot correctly obtain the attribute value of recttransform, resulting in calculation error
Ctrip starts mixed office. How can small and medium-sized enterprises achieve mixed office?
Pytest learning --base
Application of rxjs operator withlatestfrom in Spartacus UI of SAP e-commerce cloud
【避坑指南】Unity3D项目接入腾讯Bugly工具时遇到的坑
虚幻材质编辑器基础——如何连接一个最基本的材质
Blender model import UE, collision settings
Project practice, redis cluster technology learning (11)
lunix重新分配root 和 home 空间内存
VLAN experiment
Beautiful and intelligent, Haval H6 supreme+ makes Yuanxiao travel safer
快速做出原型
Configuration programmée du générateur de plantes du moteur illusoire UE - - Comment générer rapidement une grande forêt
allure--常用配置项
Notes de base sur les plans illusoires d'IA (triés en 10 000 mots)
UE4 night lighting notes
Basic notes of illusory AI blueprint (10000 words)
ERROR 1118 (42000): Row size too large (> 8126)
两数之和,求目标值