zl程序教程

您现在的位置是:首页 >  前端

当前栏目

React-Native SectionList使用

React native 使用
2023-09-27 14:28:59 时间
  • SectionList的简单实用
const titles = [
    { key: '0', data: ['目录一', '目录一', '目录一', '目录一'] },
    { key: '1', data: ['目录二'] },
    { key: '2', data: ['目录二'] }
];
<SectionList
     SectionSeparatorComponent{this.sectionSeparatorComponent.bind(this)}
     ListHeaderComponent={this.listHeaderComponent.bind(this)}
     sections={titles}
     renderItem={this.renderItem.bind(this)}
     keyExtractor={this.keyExtractor.bind(this)}
     >
</SectionList>

keyExtractor(item, index) {
        return item;
 }
listHeaderComponent() {
        return (
            <View style={{ height: autoHeight(10) }}></View>
        );
 }
sectionSeparatorComponent() {
        return (
            <View style={{ height: autoHeight(10) }}></View>
        );
}
  • 效果图如下

    image.png