我是 Angular 的新手,我正在关注这个 hero tutorial当我偶然发现这个错误时:
Type 'Event' is not assignable to type 'string'
我重现了错误here .
最佳答案
您的 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 {}
关于javascript - 类型 'Event' 不可分配给类型 'string',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66625688/