【问题标题】:How to add the ItemSeparatorComponent to the last item in FlatList如何将 ItemSeparatorComponent 添加到 FlatList 中的最后一项
【发布时间】:2020-03-19 01:06:08
【问题描述】:

我将Item SeparatorComponent 用于我的FlatList。有没有办法将该行添加到列表的最末尾,例如最后一项的底部边框?

export default Item = ({ title, data }) => {

    const renderSeparator = () => (
        <View
          style={{
            backgroundColor: 'lightgrey',
            height: 0.5,
          }}
        />
    )

    return (
        <View style={styles.container}>
            <View style={styles.title}>
                <Text style={styles.titleText}>{title}</Text>
            </View>
            <View style={styles.subItem}>
                <FlatList
                    ItemSeparatorComponent={renderSeparator}   
                    data={data}
                    renderItem={({ item }) => (
                        <SubItem 
                            title={item.title} 
                            subText={item.subText} 
                        />
                    )}
                    keyExtractor={item => item.id.toString()}
                />
            </View>
        </View>
    )
}

【问题讨论】:

  • 你可以试试 ListFooterComponent

标签: reactjs react-native react-native-flatlist


【解决方案1】:

下面

ItemSeparatorComponent={renderSeparator}

添加

ListFooterComponent={renderSeparator}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    相关资源
    最近更新 更多