属性"of"在类型"typeof Observable"上不存在 [英] Property 'of' does not exist on type 'typeof Observable
本文介绍了属性"of"在类型"typeof Observable"上不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近在我的身份验证令牌上使用了可观察的
I was recently using observable on my authentication token like
Observable.of('token');
尽管我已经导入了它,但是它一直给我上述错误.
But it keeps giving me above mentioned error, though i have already imported this.
import {Observable} from 'rxjs/Observable';
推荐答案
您需要导入它:
对于Angular> = 6.0.0
使用RxJS 6.0.0 Angular Changelog 6.0 .0
uses RxJS 6.0.0 Angular Changelog 6.0.0
import { of } from 'rxjs';
并且其用法已更改,您不再将其称为Observable:
And its usage has been changed, you no longer call it off of Observable:
of('token');
import 'rxjs/add/observable/of';
它和您在问题中所使用的一样
And it's used as you have in your question
Observable.of('token');
这篇关于属性"of"在类型"typeof Observable"上不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文