Angular2中如何处理多个http请求的结果?
时间: 2018-04-18来源:开源中国
前景提要
HDC调试需求开发(15万预算),能者速来!>>>
比如有多个http请求: this.http.get(url1).subscribe(res1=>console.log(res1)) this.http.get(url2).subscribe(res2=>console.log(res2)) this.http.get(url3).subscribe(res3=>console.log(res3))
请问es6/rxjs中有没有什么写法可以等待三个请求结束,然后再进行处理呢?
我在网上找了好几个方案,试了一下都不好使 let http1 = this.http.get(url1).subscribe(res1=>console.log(res1)) let http2 = this.http.get(url2).subscribe(res2=>console.log(res2)) let http3 = this.http.get(url3).subscribe(res3=>console.log(res3)) Observable.fornJoin([http1,http2,http3]).subscribe(res=>console.log(res)) Observable.zip(http1,http2,http3).subscribe(res=>console.log(res)) Observable.merge([http1,http2,http3]).subscribe(res=>console.log(res))
请问该如何实现呢?

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行