如何获得“Observable.of([]);";去工作? [英] How to get "Observable.of([]);" to work?
问题描述
Observable.of([]);
的正确表达式和导入是什么?
import { of } from 'rxjs';
对我不起作用.
从 RxJS 6 开始,您应该直接从 'rxjs'
导入所有创建"可观察对象(假设您有 路径图 在捆绑您的应用程序时设置).>
更详细的解释:https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#import-paths
import { of } from 'rxjs';of(1).subscribe(console.log);
见演示:https://stackblitz.com/edit/typescript-e3lxkb?file=index.ts
What is the correct expression and import for Observable.of([]);
.
import { of } from 'rxjs';
does not work for me.
Since RxJS 6 you should import all "creation" observables directly from 'rxjs'
(assuming you have path maps set when bundling your app).
More detailed explanation: https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#import-paths
import { of } from 'rxjs';
of(1).subscribe(console.log);
See demo: https://stackblitz.com/edit/typescript-e3lxkb?file=index.ts
这篇关于如何获得“Observable.of([]);";去工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!