gpt4 book ai didi

javascript - react native SectionList 布局

转载 作者:数据小太阳 更新时间:2023-10-29 04:49:03 28 4
gpt4 key购买 nike

我正在使用不同的节标题来呈现多个节。我在按我想要的方式显示它时遇到了一些麻烦。我希望我的标题位于顶部和下方,该部分的元素作为网格。

This is what I have right now

使用这段代码:

<SectionList
contentContainerStyle={styles.sectionListContainer}
renderItem={this.renderItem}
keyExtractor={this.getKey}
renderSectionHeader={this.renderSectionHeader}
shouldItemUpdate={this.shouldItemUpdate}
sections={[
{ data: mostViewedArray, key: "most_viewed", title: "Most viewed" },
{ data: recentlyArray, key: "recently", title: "Recently" }
]}
/>



const styles = StyleSheet.create({
sectionListContainer: {
flex: 1,
flexDirection: "row",
flexWrap: "wrap",
justifyContent: "space-between"
}
});

所以我希望能够不将 sectionListContainer 的 css 应用于 sectionHeader。但我不确定这是否可能。

如果有人对此有任何想法,请告诉我!

谢谢!

最佳答案

一个对我们有用的解决方案是强制 renderSectionHeader 具有整个容器的宽度,从而强制渲染元素到下一行。

如果您更新您的问题以包含 renderSectionHeader 的内容(正如 NiFi 已经提出的那样),我可以就您将如何更新 renderSectionHeader 提供更详细的答案。

关于javascript - react native SectionList 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43351080/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com