提问者:小点点

嵌套的React Native ScrollView需要两次点击才能开始滚动


我在另一个ScrollView中有一个ScrollView。我注意到,为了使嵌套的滚动视图开始滚动,我必须点击两次。

我尝试使用一些属性,如scrollenablednestedscrollenabledkeyboardshouldpersisttaps=“always”,但这些都没有帮助。

我不能提供任何真实的代码,因为项目相当大,在滚动视图之间有多个组件。但是,基本结构与此类似:

<ScrollView>
  <SomeNestedComponents>
    <ScrollView
      scrollEnabled={true}
      nestedScrollEnabled={true}
      keyboardShouldPersistTaps="always"
    >
    </ScrollView>
  </SomeNestedComponents>
</ScrollView>

共1个答案

匿名用户

我建议您也尝试将keyboardshouldpersisttaps='always'放在最外面的组件上。根据这期GitHub的最终答案,这应该可以解决问题。

例如:

<ScrollView keyboardShouldPersistTaps='always'>
  <SomeNestedComponents>
    <ScrollView
      scrollEnabled={true}
      nestedScrollEnabled={true}
      keyboardShouldPersistTaps='always'
    >
    </ScrollView>
  </SomeNestedComponents>
</ScrollView>