【发布时间】:2018-07-25 19:31:15
【问题描述】:
我正在尝试映射一个反应深度为 2 级的对象,但我似乎无法让它为我的生活工作。
谁能帮我一把?
loadBeers() {
const { userData } = this.props;
if (userData.location) {
Object.keys(userData.location).map(locationitem => {
Object.keys(userData.location[locationitem].beer).map(beerItem => {
return (
<BeerItem key={beerItem}>{userData.location[locationitem].beer[beerItem].beerName}</BeerItem>
);
});
});
} else {
return 'hi';
}
}
这是对象结构:
【问题讨论】:
-
对象结构是什么?举个例子会更清楚。
-
如果您添加对象可能会有所帮助,这样人们就不必猜测了。
-
我现在已经添加了,对不起。
标签: javascript reactjs