简体   繁体   English

Angular 模块没有导出成员“fromEvent”

[英]Angular Module has no exported member 'fromEvent'

I was trying to follow along with the official Angular tutorial on practical observable usage and attempted to import the "fromEvent":我试图遵循关于实际可观察​​使用的官方 Angular 教程,并尝试导入“fromEvent”:

import { fromEvent } from 'rxjs';

However, it keeps throwing an error message which states "myApp/node_modules/rxjs/Rx" has no exported member 'fromEvent'但是,它不断抛出一条错误消息,指出“myApp/node_modules/rxjs/Rx”没有导出成员“fromEvent”

I've already searched SO and Googled, with no luck.我已经搜索过 SO 和谷歌搜索,但没有运气。

'fromEvent' appears to be part of Observable. 'fromEvent' 似乎是 Observable 的一部分。 You can import it like this:您可以像这样导入它:

import { fromEvent } from 'rxjs/observable/fromEvent';

Unlike answers elsewhere, importing "Observable" did not help, and I had to rely on VS code correctly auto suggesting where to import from (After spending quite a bit of time trying to figure out why the import did not work).与其他地方的答案不同,导入“Observable”并没有帮助,我不得不依赖 VS 代码正确地自动建议从哪里导入(花了很多时间试图找出导入不起作用的原因之后)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM