问题描述
我正在使用本机基础,并且错误是针对包含内部滚动视图的平面列表,无需将其嵌套到scrollView中 图片1代码:
<Container>
<Content>
<View>
***
</View>
<FlatList
{...props}
/>
</Content>
</Container>
图片2代码:
<View>
<View>
<View>
***
</View>
<FlatList
{...props}
/>
</View>
</View>
我希望两部分都滚动无误,有人可以帮我吗?
解决方法
您需要稍微修改您的结构
<View>
<ScrollView>
<View>
***
</View>
<FlatList
{...props}
/>
</ScrollView>
</View>
,
nativebase中的Content
本质上是滚动视图。
您可以利用FlatList
的`页眉和页脚组件功能。并将FlatList上方的内容标记为Header,然后将其标记为页脚。
const ContentAbove=()=>(
<View>**</View>
)
//Then inside the component
-----
<Container>
<FlatList
ListHeaderComponent={<ContentAbove/>}
ListFooterComponent={<ContentBelow/>}
{...props}
/>
</Container>