[英]Cannot find module '@angular/http' Angular 9
我在一个运行良好的应用程序中突然遇到错误
找不到模块“@angular/http”
import { Http } from '@angular/http'
我正在使用 http 读取 json 文件
this.http.get('assets/env/env.json').pipe(map( res => res.json()))
请帮忙
angular 在 angular 5 或 6 左右替换了 http 模块。它已被弃用一段时间。 您现在需要使用来自@angular/common/http
的HttpClient
和HttpClientModule
但请注意Http
服务和HttpClient
服务有一些重要的差异,如果它使用Http
可能会破坏您的应用程序
Http
已弃用。 使用HttpClient
import { HttpClient } from '@angular/common/http';
@angular/http
已被弃用,在最近的版本中,现在已从生成的package.json
文件中删除,请使用来自“@angular/common/http”的 HttpClient。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.