键值对在 Typescript 中可用吗? [英] Is key-value pair available in Typescript?
本文介绍了键值对在 Typescript 中可用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
键值对在打字稿中可用吗?如果是,该怎么做.谁能提供示例链接.
Is key,value pair available in typescript? If yes how to do that. Can anyone provide sample example links.
推荐答案
Typescript 中是否提供键值对?
Is key-value pair available in Typescript?
是的.称为索引签名:
interface Foo {
[key: string]: Bar;
}
let foo:Foo = {};
这里的键是 string
,值是 Bar
.
Here keys are string
and values are Bar
.
您可以将 es6 Map
用于适当的词典,由 core-js
填充.
You can use an es6 Map
for proper dictionaries, polyfilled by core-js
.
这篇关于键值对在 Typescript 中可用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文