添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
憨厚的鼠标垫  ·  博客來-Type ...·  2 天前    · 
严肃的打火机  ·  Type-Safe Event ...·  昨天    · 
刀枪不入的钥匙扣  ·  python ...·  1 年前    · 
打盹的领带  ·  java反射找不到方法-掘金·  1 年前    · 
憨厚的黄豆  ·  C# ...·  2 年前    · 

But in TypeScript, this generates an error: 但是在TypeScript中,这会产生一个错误:

The property 'prop' does not exist on value of type '{}' 类型“ {}”的值不存在属性“ prop”

How am I supposed to assign any new property to an object in TypeScript? 我应该如何在TypeScript中为对象分配任何新属性?

参考: https://stackoom.com/question/RkGB/如何在TypeScript中为对象动态分配属性

Although the compiler complains it should still output it as you require. 尽管编译器抱怨它仍应按您的要求输出。 However, this will work. 但是,这将起作用。