提问者:小点点

类型“Event”不能赋值给类型“String”


我是angular的新手,我在学习这个hero教程时,偶然发现了这个错误:

Type 'Event' is not assignable to type 'string'

我在这里复制了错误。


共1个答案

匿名用户

AppModule中缺少FormsModule导入。

import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { FormsModule } from "@angular/forms";
import { AppComponent } from "./app.component";
import { HeroComponent } from "./hero/hero.component";

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