【发布时间】:2020-09-05 17:17:00
【问题描述】:
我想要一个动态的Array<string>,然后用数组值中的key/property 生成一个动态的Object。 (用于 reactjs 打字稿中的道具使用)
这是一个示例代码:
interface Props {
buttons: Array<string>;
buttonProps?: { [key: string]: string }; //want key here to correspond with values of buttons
}
我猜你在这里使用泛型,但我不确定如何继续。
【问题讨论】:
标签: arrays typescript object generics dynamic