我正在映射我的反应应用程序中的对象列表,如下所示
(countrydata !== null) ? Object.keys(countrydata).map((item, key) => {
return (
<img src={countrydata[item].image_location}/>
)
})
我还有一个数组,它的对象数量与我上面映射的对象列表中的对象数量完全相同。我想显示数组对象中的某些数据,我尝试做这样的事情
(countrydata !== null) ? Object.keys(countrydata).map((item, key) => {
arrayOfObjects.map((arrayItem,key)=>{
return (
<div>
<img src={countrydata[item].image_location}/>
<span>{arrayItem.name}</span>
</div>
)
})
})
但无法达到我想要的结果。如何在对象列表的映射中映射对象数组?
编辑:
我的对象列表如下所示(国家数据)
place_1:{description:'',image_location:'',location:''}
place_2:{description:'',image_location:'',location:''}
place_3:{description:'',image_location:'',location:''}
我的对象数组看起来像这样(arrayOfObjects)
0: {distance: {…}, duration: {…}, status: "OK"}
1: {distance: {…}, duration: {…}, status: "OK"}
2: {distance: {…}, duration: {…}, status: "OK"}