簡體   English   中英

rxjs 6 屬性“of”在類型“typeof Observable”上不存在

[英]rxjs 6 Property 'of' does not exist on type 'typeof Observable'

剛剛從 rxjs 5/angular 5 移動到 rxjs 6/ angular 6,經歷了這個遷移指南 似乎無法弄清楚它現在應該是什么,任何幫助表示贊賞。

import { Observable, of } from 'rxjs';
[ts] 'of' is declared but its value is never read.

// trivial example of what im trying to replace
  isLoggedIn(): Observable<boolean> {
    return Observable.of(true);
  }

現在,您可以只需要導入of來自rxjs 所以....

import { Observable, of } from 'rxjs';

// trivial example of what im trying to replace
  isLoggedIn(): Observable<boolean> {
    return of(true);
  }

如果您使用的是 Angular 6 /7 或 9

import { of } from 'rxjs';

然后而不是打電話

Observable.of(res);

只是使用

of(res);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM