ScrollView 不滚动
我在世博会上尝试的示例:
<View style={{flex: 1}}>
<ScrollView
contentContainerStyle={{ flexGrow: 1 }}>
<View style={{ flex: 1, flexDirection: 'row', flexWrap: 'wrap' }}>
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
</View>
</ScrollView>
</View>
最佳答案
问题在于,在 Android 中,其他 touchable 会窃取用户的触摸事件,这就是为什么您无法滚动 ScrollView,但很多时候它在 IOS 平台上可以按预期工作。我想您只需将 onStartShouldSetResponder={() => true}
添加到包装预期 ScrollView 的 View 中。您可以尝试下面的代码吗:
<View onStartShouldSetResponder={() => true}>
<ScrollView>
<View style={{ flex: 1, flexDirection: 'row', flexWrap: 'wrap' }}>
<Item />
<Item />
<Item />
<Item />
<Item />
<Item />
</View>
</ScrollView>
</View>
希望这会有所帮助!
关于react-native - ScrollView 在 native react 中不滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56532160/