Angular6 模块没有导出的成员';http';[2305]

Angular6 模块没有导出的成员';http';[2305],angular6,Angular6,您好,我正在尝试从“@angular/common/http”导入http调用,收到错误消息,模块没有导出的成员“http” 错误:[ts]模块“e:/car/node_modules/@angular/common/http”没有导出的成员“http”。[2305] 导入{ 路由模块 }来自“@angular/router”; 进口{ 浏览器模块 }从“@角度/平台浏览器”; 进口{ NGD模块 }从“@angular/core”开始; 进口{ 批准模块 }来自“./app routing.

您好,我正在尝试从“@angular/common/http”导入http调用,收到错误消息,模块没有导出的成员“http”

错误:[ts]模块“e:/car/node_modules/@angular/common/http”没有导出的成员“http”。[2305]

导入{
路由模块
}来自“@angular/router”;
进口{
浏览器模块
}从“@角度/平台浏览器”;
进口{
NGD模块
}从“@angular/core”开始;
进口{
批准模块
}来自“./app routing.module”;
进口{
应用组件
}来自“./app.component”;
进口{
HomeComponent
}来自“./home/home.component”;
进口{
HttpClientModule
}来自“@angular/common/http”;
@NGD模块({
声明:[
应用组件,
HomeComponent,
],
进口:[
浏览器模块,
批准模块,
HttpClientModule,
RouterModule.forRoot([{
路径:“”,
组件:HomeComponent
}])
],
提供者:[],
引导:[AppComponent]
})

导出类AppModule{}
HttpClientModule
将注入
HttpClient
服务,而不是
Http

请在
HomeComponent
中的构造函数注入中使用
HttpClient

constructor(private http: HttpClient) {}

参考创建的示例代码。

Hello Ranjit代码现在运行良好,但我无法从json服务器获取数据。请您帮助我解决以下问题:导出类导出类HomeComponent实现OnInit{constructor(私有http:HttpClient){}products=[];fetchData=function(){this.http.get('((res:Response)=>{this.products=res.json();});};ngOnInit(){this.fetchData();}}}为了参考创建的示例代码,我添加了一个products.json文件,其中包含一组值,并给出了localhost地址:5555,但即使使用了这个.http.get('localhost:5555/products')。订阅((res:Response)=>{this.products=res.json();});它没有获取数据,也没有在浏览器中显示错误消息。注意:我已经安装了json服务器,并且在处理服务器使用的“npm install-g json server”中的值后,服务器工作正常对于安装,如果my End而不是
this.products=res.json()出现任何愚蠢的错误,我们深表歉意;
使用
this.products=res;
。并且签入chrome开发工具是
http://localhost:5555/products
返回所有数据。非常感谢您现在提供的帮助,以防出现任何问题。如果您有学习CRUD操作和angular pl中网格的教程或链接,我将在此处和alo询问其他问题或评论请叫我来