【发布时间】:2019-11-01 20:30:05
【问题描述】:
[{
"NS": "food",
"Brand": "bosch",
"legendKey": "5_1"
},
{
"NS": "food",
"Brand": "bosch",
"legendKey": "5_1"
},
{
"NS": "performance",
"Brand": "ge",
"legendKey": "4_2"
}]
<ul class="legend">Needstates
{
this.state.legend ? legend.map((ele, i) =>{
return(
<li>
<span key={i} style={{backgroundColor:this.state.colors[ele['legendKey'][2]-1]}}></span> {ele['NS']}
</li>
)
}
):
null
}
</ul>
这里我试图在 react.js 中映射上面的 json。 但是根据 NS 密钥,其中一些是重复的。
删除重复项后如何映射。
请看一下
【问题讨论】:
-
那是数组
-
我的是数组中的对象
标签: reactjs