【发布时间】:2020-10-31 07:18:47
【问题描述】:
您好,我正在读取这样的 JSON 响应对象。
<td className="text-right flex">
{finance.statuses.map((statuses) => {
return statuses.currencyAmounts.map((amounts) => (
<span className="pr-8" key={amounts.currencyId}>{amounts.maxGambleAmount}</span>
));
})}
</td>
它运作良好,但我需要在每个值后面用索引 amounts.currencyId 绑定全局变量数组的货币缩写,我的问题是我无法访问内部映射中的货币。
我尝试了类似货币[amounts.currencyId],但没有成功。
有人可以帮助我吗?谢谢
【问题讨论】:
-
您实际上是在寻找全球公开的“货币”,还是您可以在当前文件中
import它?如果不需要全局可用,只需打开currencies定义所在的文件并确保正在导出变量(通过export),然后您只需将其导入当前文件。 TS 文档:typescriptlang.org/docs/handbook/modules.html#import -
货币位于 mapStateToProps
标签: json reactjs typescript dictionary nested