react-native - ScrollView 在 native react 中不滚动

标签 react-native

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/

相关文章:

typescript - vscode react native : launchReactNative. js

react-native - 如何在 React Native 中进行签名捕获?

react-native - React-Navigation with redux - StackNavigator 中嵌套在 TabNavigator 中的后退按钮触发两个导航器中的后退 Action

javascript - 出现错误 Invariant Violation 试图让帧超出范围索引?

reactjs - 使用 React Native 中 Flatlist 中自定义元素的参数进行导航 : Empty parameters

react-native - React Native - 使用 AppRegistry 注册组件

react-native - 如何在 react-native-awesome-alerts 中的警报消息中插入换行符

javascript - 如何访问我的复选框组件状态?

ios - 如何设置 Jenkins 来构建使用 Carthage 的 React Native iOS 应用程序?

android-studio - 如何将 React-Native 项目集成到 Android-Studio?