繁体   English   中英

用于 JSON 数据的嵌套平面列表 - React Native

[英]Nested flatlist with array for JSON data - React Native

尝试将它们显示为列表项,日期(2020-05-10,2020-05-22 等...)为 header 和 Hokey,日期标题下的购物作为列表项。

{
   "2020-05-10":[
      {
         "title":"Hiking"
      },
      {
         "title":"Shopping"
      }
   ],
   "2020-05-22":[
      {
         "title":"Hiking"
      },
      {
         "title":"Football"
      }
   ],
   "2020-05-28":[
      {
         "title":"Hiking"
      },
      {
         "title":"Football"
      },
      {
         "title":"Cricket"
      }
   ]
}

使用<SectionList/>

https://reactnative.dev/docs/sectionlist

类似于 FlatList 和 ScrollView,但允许部分(标题)和您需要的演示文稿。 您将不得不对 map 数据进行不同的处理,例如:

const sectionListData = [
 {
  sectionHeader: '22-05-2020',
  data: [{title: 'Football}, {title: 'Hockey'}]
 },
 ...
]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM