当前位置:网站首页>promise.all
promise.all
2022-04-22 05:59:00 【周周池】
promise.all()该方法用于将多个Promise实例,包装成一个新的Promise实例。
var p = Promise.all([p1,p2,p3]);
- 只有p1、p2、p3的状态都变成fulfilled(成功),p的状态才会变成fulfilled(成功),此时p1、p2、p3的返回值组成一个数组,传递给p的回调函数。
- 只要p1、p2、p3之中有一个被rejected(失败),p的状态就变成rejected(失败),此时第一个被reject的实例的返回值,会传递给p的回调函数
代码
Getlist(loadType = true) {
const promises = [this.$api.user.getMemberCardList, this.$api.user.getMemberCardList, this.$api.user
.getCashCardList, this.$api.user.getCashCardList].map((item, index) => {
let data = {
}
if (index == 0 || index == 1) {
data = {
ctype: this.list[index].ctype
}
}
if (index == 2 || index == 3) {
data = {
type: this.list[index].ctype
}
}
return this.$request({
url: item,
method: "POST",
data: data,
loading: loadType
})
})
Promise.all(promises).then(values => {
//values 请求到的数据集合
values.forEach((item, index) => {
if (item.data.length > 0) {
item.data.forEach(myitem => {
})
}
})
this.list.forEach((item, index) => {
this.list[index].Pagedata = values[index].data
})
this.$nextTick(() => {
this.IsShow = true
})
uni.stopPullDownRefresh();
uni.hideLoading()
})
},
版权声明
本文为[周周池]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45444562/article/details/123210252
边栏推荐
- 如何清除浮动?
- Digital beauty technology won the "top ten intelligent risk control management innovation award" of the banker
- How to set the size of a window in a window function
- Mvcc transaction isolation in PostgreSQL
- A set of SQL statements supports both Oracle and MySQL?
- Mapping of oid and relfilenode in PostgreSQL
- 从零开始学安卓(kotlin)一 ——入门
- 剑指offer:对称的二叉树(递归 迭代leetcode 101)
- Scenario of PostgreSQL online adjusting the maximum number of connections
- 剑指offer:栈的压入、弹出序列
猜你喜欢
随机推荐
使用AES加密-复用前人的智慧
How can enterprise risk control build four systems to achieve overall prevention and control?
从零开始学安卓(kotlin)三——BaseActivity、ActivityCollector
COM in Wine(1)——COM基本概念
Uniapp global interception 401 jumps to the login page
webService接口编写并发布与webService接口的调用(二)
The difference between watch and computed
pixel手机救砖教程
Liang Kun, CTO of Shumei technology, suggested: technology + operation combination to prevent and control "pig killing plate"
Functions and methods in Scala, function creation, closure and corrilization
POM文件浅析
Introduction to postgreshub Chinese resource network
小程序调用扫描二维码功能并跳转到二维码指定的路径
记一次 Redhat 6 yum无法使用的问题
EXCEL VLOOKUP函数的使用(二)
Uniapp wechat applet user authorization to obtain current location information Tencent map
创新实训(二)任务划分
ArcMAP TIN与栅格DEM的坡度坡向对比分析
关于一段小程序的思考
MySQL在面试中经常被问到的经典问题。









