gpt4 book ai didi

angular - 导入 forkJoin 但仍然得到 "not a function"

转载 作者:行者123 更新时间:2023-12-02 00:19:57 24 4
gpt4 key购买 nike

我将 forkJoin 导入为

import 'rxjs/add/observable/forkJoin';

但我的控制台仍然出现错误:

__WEBPACK_IMPORTED_MODULE_2_rxjs_Observable__.a.forkJoin is not a function

我在 Angular CLI 编译器(使用 ngserve)中没有收到此错误,VS Code 也没有提示。现在有不同的运行 forkJoin 的方法吗?我正在运行最新版本的 Angular (5.*),以及 RxJS 5.5.*。

根据要求,它的调用方式如下:

Observable.forkJoin(
this.eventService.getTypes().first(),
this.eventService.getDates().first()
).pipe(

最佳答案

对于 RxJS 5.5,您应该将其用作函数。我不确定 Angular CLI 1.5 及更高版本是否配置为使用 RxJS 的旧原型(prototype)修补风格。

import { forkJoin } from 'rxjs/observable/forkJoin'

...

forkJoin(...).pipe(...).subscribe(...);

关于angular - 导入 forkJoin 但仍然得到 "not a function",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48294223/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com