可观察类型上不存在 mergeMap [英] mergeMap does not exist on type observable
问题描述
我试图在 rxjs6
中使用 mergeMap
并且我收到此错误:
I am trying to use mergeMap
in rxjs6
and i am getting this error:
属性mergeMap"不存在于类型Observable<{}>"
我试过 import 'rxjs/add/operator/mergeMap';
但它不起作用.
I have tried import 'rxjs/add/operator/mergeMap';
and it is not working.
我做错了什么?
import {from, Observable} from 'rxjs';
export class Test {
public doSomething(): Observable<any> {
return from(...).mergeMap();
}
}
推荐答案
没错,从 RxJS 6 开始,运算符的补丁"样式已被删除.您最好更新代码以仅使用可管道"运算符或安装 rxjs-compat
向后兼容 RxJS 5 的包.
That's correct, the "patch" style of operators has been removed since RxJS 6. You should better update your code to use only "pipeable" operators or install rxjs-compat
package that provides backwards compatibility with RxJS 5.
更详细的描述见官方文档:https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md
For more detailed description see official doc: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md
...更具体地说,这部分:https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md#backwards-compatibility
... more specifically this part: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md#backwards-compatibility
这篇关于可观察类型上不存在 mergeMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!