4

有没有人在 SectionLists 中有更详细的异构渲染示例?

<SectionList
  sections={[ // heterogeneous rendering between sections
      {data: [...], key: ..., renderItem: ...},
      {data: [...], key: ..., renderItem: ...},
      {data: [...], key: ..., renderItem: ...},
  ]}
/>

非常感谢帮助!

4

1 回答 1

5

这是我如何为 SectionLists 实现异构渲染的示例片段

所以这就是我的sectionsData数组的样子

const sectionsData = { key: 'On Air', data: onAirShows, renderItem: ({item}) => <View><Text>{item}</Text></View> //This is what you want this particular section to look like }, { key: 'Off Air', data: offAirShows, renderItem: this._renderOffAirItems //Same thing for here. You can define it as a helper method and call it here like so }

<SectionList data={sectionsData} />

注意:onAirShowsandoffAirShows是一个数组

于 2017-07-25T13:29:33.433 回答