Angular 5 rxjs 5.5.2-导入间隔错误-“无法读取未定义的属性'调用'

gobuckeyes2

尝试导入“间隔”时出现错误“无法读取未定义的属性'调用'”

我的进口是:

import { Observable } from 'rxjs/Observable';   
import 'rxjs/add/observable/merge';   
import 'rxjs/add/observable/of';   
import 'rxjs/add/operator/catch';   
import 'rxjs/add/operator/map';   
import 'rxjs/add/operator/startWith';   
import 'rxjs/add/operator/switchMap';   
import 'rxjs/add/operator/debounceTime';   
import 'rxjs/add/observable/interval';

如果我删除了最后一次导入,则效果很好。

我在控制台中遇到此错误

Uncaught TypeError:无法读取对象... / .. / .. / ..处eval(home.component.ts:12)处webpack_require(inline.bundle.js:55)处未定义的属性“调用” 。 /src/app/home/home.component.ts(main.bundle.js:134)在webpack_require(inline.bundle.js:55)在eval(app.module.ts:23)在Object ... /。 ./../../../src/app/app.module.ts(main.bundle.js:52)在webpack_require(inline.bundle.js:55)在eval(main.ts:4)在对象... / .. / .. / .. / .. / src / main.ts(main.bundle.js:394)位于webpack_require(inline.bundle.js:55)webpack_require @ inline.bundle.js: 55(匿名)@ home.component.ts:12 ../../../../../src/app/home/home.component.ts @ main.bundle.js:134 webpack_require@ inline.bundle.js:55(匿名)@ app.module.ts:23 ../../../../../src/app/app.module.ts @ main.bundle.js: 52 webpack_require @ inline.bundle.js:55(匿名)@ main.ts:4 ../../../../../src/main.ts @ main.bundle.js:394 webpack_require @内联.bundle.js:55 0 @ main.bundle.js:409 webpack_require @ inline.bundle.js:55 webpackJsonpCallback @ inline.bundle.js:26(匿名)@ main.bundle.js:1

更新我认为也许问题出在使用间隔?我尝试使用计时器如下,它工作。

import { timer } from 'rxjs/observable/timer';  

var numbers = timer(5000);
numbers.subscribe(x => console.log(x));

但这会产生“无法读取未定义的属性'调用'”

import { interval } from 'rxjs/observable/interval';

var numbers = interval(1000);
numbers.subscribe(x => console.log(x));
金·克恩

管道运算符是导入和使用rxjs运算符的新的首选方式。有关更多信息,请参阅rxjs docs

import { map, filter, scan } from 'rxjs/operators';
source$.pipe(
  filter(x => x % 2 === 0),
  map(x => x + x),
  scan((acc, x) => acc + x, 0)
)

可以导入其他运算符(例如创建Observables)并直接使用:

import { combineLatest } from 'rxjs/observable/combineLatest';

combineLatest(this.first$, this.second$, (first, second) => ({first, second}))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

错误:无法读取未定义Angular 5的属性'cloneDeep'

为什么Angular 5 Transition抛出AppComponent.html:2错误TypeError:无法读取未定义的属性'forEach'

无法读取未定义的属性“ healthCarePlans”(Angular5)

Angular 5-“无法读取未定义的属性”

Angular 5 无法读取未定义的属性“目标”

TypeError:无法读取未定义的属性'splice'-Angular 5

Angular 5无法读取未定义的属性“删除”

Angular 5 TypeError:无法读取未定义的属性

Angular 5:TypeError:无法读取未定义的属性“密码”

无法读取未定义的@ViewChild的属性,Angular 5无法正常工作

无法读取Typescript Angular 5中未定义的属性somevalue

TypeError:无法读取未定义的Ionic 3 / Angular 5的属性“ get”

Angular5-TypeError:无法读取未定义的属性“模板”

Angular 5-动态组件加载器-无法读取未定义的属性'viewContainerRef'

CKEditor 5抛出无法读取Angular6项目中未定义的属性“创建”

角5-可观察到的返回错误无法读取未定义的属性

HTML5 视频:未捕获的类型错误:无法读取未定义的属性“0”

角5:错误TypeError:无法读取未定义的属性'toLowerCase'

无法将'rxjs'导入angular 5应用程序

CKEditor5:无法读取未定义的属性“pluginName”

无法读取未定义的属性-p5js

角度 5 数组无法读取未定义的属性“”

Ionic v5/Angular 8:HttpClient.get().subscribe() 返回 TypeError:无法读取未定义的属性“句柄”

无法读取Angular 2中未定义的属性“错误”?

类型错误:无法读取未定义的属性“位置” - 连接反应路由器 - ReactRouter v5

收到错误“p5practice.js:97 Uncaught TypeError:无法读取未定义的属性‘y’”

p5js-未捕获的类型错误:无法读取未定义的属性“eats”(草图:第 76 行)

摇树RxJS Angular 5

Angular 5-Rxjs分叉