Promise.all 和 Promise.race 处理异步问题

Promse.all在处理多个异步处理时非常有用,比如说一个页面上需要等两个或多个ajax的数据回来以后才正常显示,在此之前只显示loading图标。
参考网址:https://www.jianshu.com/p/7e60fc1be1b2

Promise.all([this.fetchJZHZData(jgbm, bzrq, czyh), this.fetchZDHZData(jgbm, bzrq, czyh)]).then((result) => {
	this.jzhzTable = result[0];
	this.zdhzTable = result[1];
	this.sszje = this.zdhzTable[0].sszje;
}).finally(() => this.loading2 = false);

发布了51 篇原创文章 · 获赞 8 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_44171757/article/details/102859605