【发布时间】:2022-07-11 22:31:27
【问题描述】:
我有地图对象:
const myMap = new Map<number,string>([
[10, "text1"],
[15, "text2"],
[20, "text3"]
])
寻找如何在 React JSX 中迭代此映射的方法。 提前谢谢你
【问题讨论】:
标签: reactjs typescript dictionary jsx
我有地图对象:
const myMap = new Map<number,string>([
[10, "text1"],
[15, "text2"],
[20, "text3"]
])
寻找如何在 React JSX 中迭代此映射的方法。 提前谢谢你
【问题讨论】:
标签: reactjs typescript dictionary jsx
let nodes: React.ReactNode[] = [];
myMap.forEach((value, key) => {
nodes.push(<your jsx>);
})
return nodes; // if you are in a component where you want to render
【讨论】: