如何获得“Observable.of([]);";去工作? [英] How to get "Observable.of([]);" to work?

查看:22
本文介绍了如何获得“Observable.of([]);";去工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆