javascript - 类型“事件”不可分配给类型“字符串”
问题描述
我是Angular 的新手,当我偶然发现这个错误时,我正在关注这个英雄教程:
Type 'Event' is not assignable to type 'string'
我在这里重现了错误。
解决方案
您的 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 {}
推荐阅读
- html - 启用 parent:active 时如何忽略子元素活动区域?
- java - 我的 JavaFX 项目没有在 Eclipse 之外运行
- java - 我应该为Java Spring程序中的所有类添加@Component注解吗?
- snowflake-cloud-data-platform - 字节扫描为 100 后,雪花查询仍在运行
- scala - 在本地分发中运行 spark.read.csv("...") 需要哪些依赖项?
- c# - .NET MySql ArgumentNullException 在 GetCustomAttributes 中打开
- angular - RxJS 从发出的 observable 中获取值
- ios - 如果 UIPasteboard.general.string 返回 nil,为什么 UIPasteboard.general.string?.append("another") 会崩溃?
- postgresql - 完全升级后新安装 Kali Linux 时出现 Armitage 'Connection denied' 错误
- php - 爆炸 Foreach