这是我的代码:
{seasons.map(k => (
<TabPanel key={k} className="list-episode">
<Scrollbars style={{ height: this.state.screenSize }}>
{arrEpisodes[k].map(i => (
<div key={i.ID} className="episode">
但是,行{arrEpisodes [k] ...不起作用,为什么?
答案 0 :(得分:2)
更改
{seasons.map(k => (
<TabPanel key={k} className="list-episode">
<Scrollbars style={{ height: this.state.screenSize }}>
{arrEpisodes[k].map(i => (
<div key={i.ID} className="episode">
收件人
{seasons.map((k, index)=> (
<TabPanel key={k.ID} className="list-episode">
<Scrollbars style={{ height: this.state.screenSize }}>
{arrEpisodes[index].map(i => (
<div key={i.ID} className="episode">
这里的问题是您正在使用数据作为arrEpisodes数组的索引位置而不是索引,这就是为什么它失败的原因。您需要将Seasons数组的索引传递给arrEpisodes数组。还要将id设置为TabPanel的键,而不是对象的键,即代码中的k