首页 > 解决方案 > React Native Flexwrap 中断 ScrollView 不会滚动

问题描述

我试图让我的物品水平包装,他们确实做到了。只有当我添加 flexWrap: "wrap" 时,滚动视图才会决定根本不滚动。

<ScrollView contentContainerStyle={{ flexDirection: 'row', flexWrap: 'wrap', alignItems: 'flex- 
     start',}}>  
    <FrameComponent />
    <FrameComponent />
    <FrameComponent />
    <FrameComponent />
    <FrameComponent />
    ...
</ScrollView>

使用 FrameComponent 渲染

<View>
    <Text>
        ...
    </Text>
<View>

框架组件的样式是一些简单的 flex 和 margin 东西。

这与所有其他设置一起滚动,但是一旦我添加了 flexWrap,它就会变得很糟糕。

谢谢。

标签: react-nativeflexboxscrollview

解决方案


将水平 = {true} 属性传递给您的 ScrollView 并删除 flex wrap 和 flexDirection 样式。

<ScrollView horizontal = {true}>
...
</ScrollView>

React Native 中的水平滚动视图


推荐阅读