我映射了多个对象。
[{name:"y", country:"US", cities:[obj,obj,ob]},{name:"y", country:"US", cities:[obj,obj,ob]}]
我怎样才能嵌套一个循环,所以我首先遍历对象,然后遍历(在这个例子中)城市?谢谢!
我没有嵌套外观的渲染函数如下所示:
render() {
const persons = this.state.name.map((item, i) => {
return (
<div>
<h5> {item.name} </h5>
<h5> {item.country} </h5>
//here I would like to show the cities
</div>
);
});
return (
<div>
<div className = "panel-list">
All: {persons}
</div>
</div>
);
}
城市对象示例:
[{visitors:34, rating:4},
{visitors:1234, rating:1},
{visitors:124, rating:2}]