簡體   English   中英

當廣告在我的文件上添加代碼,就像在視頻上一樣時,我得到錯誤“ ./src/app/app.module.ts找不到模塊:錯誤:無法解析'@ angular / http'”

[英]when ad add code on my file as it is on video i get error “./src/app/app.module.ts Module not found: Error: Can't resolve '@angular/http'”

我是新世界。 我試圖學習此框架,但它是如此困難!...因此在我的第一個示例中,我遇到了錯誤:

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

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

錯誤是:

編譯失敗。

./src/app/app.module.ts找不到模塊:錯誤:無法解析'C:\\ Hosts \\ ng4tutorial \\ src \\ app'中的'@ angular / http'

我錯過了什么..?

檢查角度: ng --version

請注意,在Angular 4.3版本中不推薦使用Http

如果您有較新的版本,我建議您使用新的Api: HttpClient ,它附帶許多更新並支持進度事件,默認情況下json反序列化,攔截器和許多其他強大功能。

https://angular.io/guide/http上查看如何使用它以及更多內容

暫無
暫無

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

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