添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
朝气蓬勃的油条  ·  Fullstack part9 |·  2 月前    · 
狂野的荔枝  ·  smartthings-cli ...·  2 月前    · 
活泼的小蝌蚪  ·  VSTO for Microsoft ...·  2 年前    · 
斯文的香烟  ·  一篇带你快速上手 ...·  2 年前    · 
性感的青椒  ·  visual studio ...·  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. 但是,这将起作用。