本文介绍了属性“forkJoin"在类型“typeof observable"上不存在 - angular2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望主要使用此处接受的答案来试验 forkJoin:

I was looking to experiment with a forkJoin mainly using the accepted answer here:

Angular2 Observable.forkJoin of observable variables - ReferenceError: Observable is not定义

我收到上述错误消息,因为 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 07:13