Cannot find module 'rxjs/subject/BehaviorSubject'

醉酒当歌 提交于 2019-12-09 05:01:35

问题


I am using Angular 2.

When I use either of these two, my program runs well:

import { BehaviorSubject } from 'rxjs/Rx';
import { BehaviorSubject } from 'rxjs';

However, I try to use the following way:

import { BehaviorSubject } from 'rxjs/subject/BehaviorSubject';

But I failed, my browser console shows:

Uncaught Error: Cannot find module 'rxjs/subject/BehaviorSubject'

How can I use third way correctly? Thanks


回答1:


import {BehaviorSubject} from 'rxjs/BehaviorSubject';

rxjs 6.x

import {BehaviorSubject} from 'rxjs';

See also

  • Property 'of' does not exist on type 'typeof Observable
  • https://stackoverflow.com/a/49665105/3232832


来源:https://stackoverflow.com/questions/36701041/cannot-find-module-rxjs-subject-behaviorsubject

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