【问题标题】:React Native Heterogenous Section ListReact Native 异构节列表
【发布时间】:2017-06-27 13:59:21
【问题描述】:

有没有人有更详细的异构渲染示例 部分列表?

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

非常感谢您的帮助!

【问题讨论】:

    标签: react-native react-native-flatlist


    【解决方案1】:

    这是我如何为 SectionLists 实现异构渲染的示例 sn-p

    这就是我的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} />

    注意:onAirShowsoffAirShows 是一个数组

    【讨论】:

    • 在上面的例子中,如果没有来自 JSON 的数据到第 2 部分我如何动态渲染部分?
    猜你喜欢
    • 1970-01-01
    • 2016-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多