属性'from'在类型'typeof Observable'上不存在,角度为6? [英] Property 'from' does not exist on type 'typeof Observable', angular 6?
本文介绍了属性'from'在类型'typeof Observable'上不存在,角度为6?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我将我的5.2.10角项目更新为6角.
我一步一步做https://update.angular.io/
,除非Observable.from
一切正常
在服务中,我使用Observable.from(this.user)
如下:
I updated my angular 5.2.10 project to angular 6.
I did step by step https://update.angular.io/
, everything is OK unless Observable.from
In a service I used Observable.from(this.user)
as following:
import { Observable } from 'rxjs/Observable';
...
Observable.from(this.users)// this.users is an array
可以,但是在角度6中发生以下错误
It was OK, but in angular 6 the following error occurred
Property 'from' does not exist on type 'typeof Observable'
我将其更改如下
import { Observable, from } from 'rxjs';
但是没有再次发生变化和错误!
But no change and error occurred again!
推荐答案
在 rxjs @ 6 中,您可以将from
用作独立功能:
In rxjs@6 you can use from
as standalone function:
import { from } from 'rxjs';
...
from(this.users);
或
import { from as observableFrom } from 'rxjs';
...
observableFrom(this.users);
另请参阅迁移到rxjs6指南
See also migration to rxjs6 guide
这篇关于属性'from'在类型'typeof Observable'上不存在,角度为6?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文