本文介绍了属性'forkJoin'在'typeof observable'类型上不存在-angular2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试使用forkJoin进行实验,主要是在这里使用公认的答案:
I was looking to experiment with a forkJoin mainly using the accepted answer here:
可观察变量的Angular2 Observable.forkJoin-ReferenceError:不是可观察的已定义
我收到上述错误消息,因为forkJoin不可用.
I'm getting the above error message as forkJoin isn't available.
有人知道为什么吗?
推荐答案
Angular 6对此做了一些修改. forkJoin已被转换为常规函数,而不是:
Angular 6 changes this up a bit. forkJoin has been converted to a regular function so, instead of:
import {Observable} from 'rxjs/Observable';
...
return Observable.forkJoin(
this.http.get('someurl'),
this.http.get('someotherurl'));
使用:
import {forkJoin} from 'rxjs';
...
return forkJoin(
this.http.get('someurl'),
this.http.get('someotherurl'));
您可以转到 https://www. metaltoad.com/blog/angular-6-upgrading-api-calls-rxjs-6 了解更多说明.
You can go to https://www.metaltoad.com/blog/angular-6-upgrading-api-calls-rxjs-6 for more explanation.
这篇关于属性'forkJoin'在'typeof observable'类型上不存在-angular2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!