如何获得"Observable.of([]);"去工作? [英] How to get "Observable.of([]);" to work?
本文介绍了如何获得"Observable.of([]);"去工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么是正确的表达式,并为Observable.of([]);
导入.
What is the correct expression and import for Observable.of([]);
.
import { of } from 'rxjs';
对我不起作用.
推荐答案
自RxJS 6开始,您应该直接从'rxjs'
导入所有创建"的可观察对象(假设您具有
Since RxJS 6 you should import all "creation" observables directly from 'rxjs'
(assuming you have path maps set when bundling your app).
更详细的说明: 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
这篇关于如何获得"Observable.of([]);"去工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文