如何获得"Observable.of([]);" 上班?

Ros*_*eur 7 rxjs typescript rxjs5 angular rxjs6

什么是正确的表达和导入Observable.of([]);.

import { of } from 'rxjs'; 不适合我.

mar*_*tin 16

从RxJS 6开始,您应该直接导入所有"创建"可观察对象'rxjs'(假设您在捆绑应用程序时设置了路径映射).

更详细的解释:https://github.com/ReactiveX/rxjs/blob/master/MIGRATION.md#import-paths

import { of } from 'rxjs';

of(1).subscribe(console.log);
Run Code Online (Sandbox Code Playgroud)

请参阅演示:https://stackblitz.com/edit/typescript-e3lxkb?file = index.ts