Rxjs import issues in Angular 6

非 Y 不嫁゛ 提交于 2019-12-13 17:57:25

问题


I am facing some weird issues while working with Angular 6 and Rxjs 6. When I import as below

Import { forkJoin } from 'rxjs/internal/observable/forkJoin';

I am getting issue as

but when I use import as

import { forkJoin } from 'rxjs/';

it works perfectly.

I used the same method to merge operator but when i used import as

import { merge } from 'rxjs/';

but it thrown error as above and it works fine if i use

import { merge } from 'rxjs/internal/observable/merge';

Could someone point out where is the problem? Why is this working differently?

PS: It's working on reloading page but alternately.


回答1:


Use it like this,

import { merge } from 'rxjs/operators';

Check you rxjs version, it should be 6+

Stackblitz example: https://stackblitz.com/edit/typescript-bcsl1r




回答2:


Use :

 import {merge} from 'rxjs';

OR

import { merge } from 'rxjs/operators';

Refer: https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md



来源:https://stackoverflow.com/questions/52923192/rxjs-import-issues-in-angular-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!