android - 为什么变量数据突然变成了item
问题描述
<View style={styles.container}>
<SectionList
sections={[
{ title: 'D', data: ['Devin'] },
{
title: 'J',
data: ['Jackson', 'James', 'Jillian', 'Jimmy', 'Joel', 'John', 'Julie'],
},
]}
renderItem={({ item }) => <Text style={styles.item}>{item}</Text>}
renderSectionHeader={({ section }) => (
<Text style={styles.sectionHeader}>{section.title}</Text>
)}
keyExtractor={(item, index) => index}
/>
</View>;
你能告诉我为什么变量data
突然变成item
,我不知道这里发生了什么。
解决方案
您是否试图告诉为什么您的部分下的数据名称已更改为 renderItem 中的项目对?
SectionList 将作为for loop
从中获取数据的地方工作
{[
{ title: 'D', data: ['Devin'] },
{ title: 'J', data: ['Jackson', 'James', 'Jillian', 'Jimmy', 'Joel', 'John', 'Julie'] }
]}
并作为项目一一返回。您也可以将项目更改为数据,它只是一个变量。
希望你得到答案。
推荐阅读
- flutter - 在 Google Play 管理中心更新应用时如何更改版本号和内部版本号?
- arrays - 如何从数组内部的对象访问键:值对?
- java - 如何修复 checkmarx 错误以清理有效负载
- quarkus - Quarkus 中的 Cookie 管理
- javascript - js模块导入排序和执行问题
- python - 如何在行空间中创建自定义尺寸
- reactjs - 在 react 中调用 useMutation 钩子后重新获取查询不起作用
- python - 我试图获取两列中两个字符串之间的距离并将结果放在下一个第三列,但为什么它对所有人产生相同的结果?
- java - Android 11 之后在内部存储中创建目录
- jquery - 错误使用 removeProp() 时 jquery Migrate 插件没有警告