【问题标题】:Could Not find HttpObserve from '@angular/common/http/src/client' after upgrading to angular 8升级到 Angular 8 后无法从“@angular/common/http/src/client”找到 HttpObserve
【发布时间】:2020-10-06 10:57:52
【问题描述】:
import { HttpObserve } from '@angular/common/http/src/client';
import { HttpParams, HttpHeaders } from '@angular/common/http';

type responseType = 'arraybuffer' | 'blob' | 'json' | 'text';

export interface RequestOptions {
  body?: any;
  headers?: HttpHeaders;
  params?: HttpParams;
  observe?: HttpObserve;
  reportProgress?: boolean;
  responseType?: responseType;
  withCredentials?: boolean;
}

升级到 Angular 8 后,上面的代码抛出了下面提到的错误,有什么帮助吗?

error TS2307: Cannot find module '@angular/common/http/src/client'.

【问题讨论】:

标签: angular interface client httpresponse observers


【解决方案1】:

Angular update guide 说:

如果您使用旧版 HttpModule 和 Http 服务,请切换到 HttpClientModule 和 HttpClient 服务。 HttpClient 简化了默认的人体工程学(您不再需要映射到 JSON),现在支持类型化的返回值和拦截器。阅读更多angular.io

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-07
    • 2020-07-01
    • 2022-11-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-16
    • 2019-10-26
    相关资源
    最近更新 更多