当前位置:网站首页>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()
})
边栏推荐
- 2.14 is it Valentine's day or Valentine's day when the mainstream market continues to fluctuate and wait for changes?
- 虛幻AI藍圖基礎筆記(萬字整理)
- MongoDB-快速上手MongoDB命令行的一些简单操作
- 【Unity3D】制作进度条——让Image同时具有Filled和Sliced的功能
- Ctrip starts mixed office. How can small and medium-sized enterprises achieve mixed office?
- MPLS experiment
- MySQL -- time zone / connector / driver type
- [illusory] weapon slot: pick up weapons
- 【虚幻4】从U3D到UE4的转型之路
- Commutateur Multi - lentilles Blender
猜你喜欢

Test -- Summary of interview questions
![[Fantasy 4] introduction and use of UMG components (under update...)](/img/33/7e3b74192b7fd73d5145f85e061d1f.png)
[Fantasy 4] introduction and use of UMG components (under update...)

Ue5 - AI pursuit (blueprint, behavior tree)

ue虛幻引擎程序化植物生成器設置——如何快速生成大片森林

Redis set password

两数之和,求目标值

Bookmark collection management software suspension reading and data migration between knowledge base and browser bookmarks

Mock Server基本使用方法

Following nym, the new project Galaxy token announced by coinlist is gal

sqoop创建job出现的一系列问题解决方法
随机推荐
[unity3d] production progress bar - make image have the functions of filled and sliced at the same time
[illusory] automatic door blueprint notes
KS009基于SSH实现宠物管理系统
Pytest learning --base
[unreal] key to open the door blueprint notes
Vscode set JSON file to format automatically after saving
Configuration programmée du générateur de plantes du moteur illusoire UE - - Comment générer rapidement une grande forêt
stm32和电机开发(上位系统)
[Fantasy 4] the transformation from U3D to UE4
[unity3d] cannot correctly obtain the attribute value of recttransform, resulting in calculation error
Spatial interpretation | comprehensive analysis of spatial structure of primary liver cancer
[leetcode] sword finger offer 53 - I. find the number I in the sorted array
sqoop创建job出现的一系列问题解决方法
allure--常用配置项
Bookmark collection management software suspension reading and data migration between knowledge base and browser bookmarks
Application of rxjs operator withlatestfrom in Spartacus UI of SAP e-commerce cloud
Pytest framework implements pre post
Zlib download and use
ue虚幻引擎程序化植物生成器设置——如何快速生成大片森林
flume 190 INSTALL