Jack Asked:2020-02-20 19:07:56 +0000 UTC2020-02-20 19:07:56 +0000 UTC 2020-02-20 19:07:56 +0000 UTC 在 TypeScript 中是否可以在对象中设置不固定数量的某种类型的字段? 772 例如,我希望一个对象具有无限数量的字段,但它们都是字符串。 javascript 1 个回答 Voted Best Answer ThisMan 2020-02-20T19:15:31Z2020-02-20T19:15:31Z 这似乎很容易做到: interface Foo { [key:string]: string // all key must be string } 你可以在这里阅读更多内容:https ://basarat.gitbooks.io/typescript/content/docs/types/index-signatures.html
这似乎很容易做到:
你可以在这里阅读更多内容:https ://basarat.gitbooks.io/typescript/content/docs/types/index-signatures.html