2017-08-02 60 views
1

enter image description here有一些誤差httpclientmodule: 我有app.module.ts且有代碼:角2誤差httpcliendmodule

import { NgModule }  from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { FormsModule } from '@angular/forms'; 
import { AppComponent } from './app.component'; 
import {HttpClientModule } from '@angular/http'; 

@NgModule({ 
    imports:  [ BrowserModule, FormsModule, HttpClientModule ], 
    declarations: [ AppComponent ], 
    bootstrap: [ AppComponent ] 
}) 
export class AppModule { } 

和錯誤: nodemodules/@角/ HTTP/HTTP沒有導出部件'HttpClientModule'

+0

看到在角HTTP和之間的HTTPClient [差分4?](https://stackoverflow.com/questions/45129790/difference-between-http-and-httpclient-in-angular-4/451 29865#45129865) –

回答

4

應該從@angular/common/http進口

import {HttpClientModule} from '@angular/common/http'; 

確保ÿ OU已經安裝[email protected]^4.3.0changelog

又見文檔

Plunker Example

+0

我試了一下,但有錯誤:無法找到模塊「@角/普通/ HTTP」您正在使用哪個版本的角度 – shoopik

+0

@shoopik? – yurzui

+0

毫米,我怎麼檢查它?在JSON我看下:「@角/常見」:「〜4.0.0」, 「@角/編譯」:「〜4.0.0」, – shoopik