作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将 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/
我是一名优秀的程序员,十分优秀!