angular – 错误rxjs_Observable __.Observable.forkJoin不是函
发布时间:2020-12-17 07:35:17 所属栏目:安全 来源:网络整理
导读:我在angualr-cli应用程序中使用Rxjs. 在viewer.component.ts中 //Other Imports import { Observable } from 'rxjs/Observable'; //omitting for brevity export class ViewerComponent implements OnInit,AfterViewInit,OnDestroy { someFunction(someArg){
我在angualr-cli应用程序中使用Rxjs.
在viewer.component.ts中 //Other Imports import { Observable } from 'rxjs/Observable'; //omitting for brevity export class ViewerComponent implements OnInit,AfterViewInit,OnDestroy { someFunction(someArg){ //omitting for brevity let someArray: any = []; //Add some info Observable.forkJoin(someArray).subscribe(data => { //Do something with data }); } //omitting for brevity } 我得到了错误 ERROR TypeError: __WEBPACK_IMPORTED_MODULE_2_rxjs_Observable__.Observable.forkJoin is not a function at ViewerComponent.webpackJsonp../src/app/component/viewer.component.ts.ViewerComponent.someFunction(http://localhost:4200/main.bundle.js:4022:73) at http://localhost:4200/main.bundle.js:3951:31 但如果我完全导入Rxjs(导入’rxjs’;)一切正常.没错. 关于如何解决这个问题的任何指示.
如
here所述,您有两种选择:
>将所有运算符作为单个包导入 在第一种情况下,您将使用如下导入: import Rx from 'rxjs/Rx'; Rx.Observable.forkJoin(1,2,3) 在第二个像这样: import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/forkJoin'; 我相信你正在寻找的是第二种选择. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- angularjs – 针对父状态的角度ui-router解析
- 《数据结构》实验一:VC编程环境灵活应用
- scala – 给定一些路径依赖类型的值,我如何获得“容器”的实
- Bootstrap在windows phone 8 下不兼容解决方案
- Angular2:第二次避免使用DOM渲染
- angularjs – 如何在角线路上拥有通配符
- twitter-bootstrap – Bootstrap 3和Sticky Footer
- scala – 在Mappers之间共享信息的增强版MapReduce有什么好
- 在AngularJS Bootstrap中添加数据切换属性时,单选按钮绑定不
- “vaw”在正常模式下的vim中意味着什么(以及“caw”和“daw