添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
精明的手套  ·  java ...·  2 年前    · 
微笑的水桶  ·  浅谈EditorConfig、Prettie ...·  2 年前    · 
彷徨的充电器  ·  创作你的创作 - 简书·  2 年前    · 
干练的火柴  ·  "Could not get any ...·  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. 但是,这将起作用。