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

Nested React Native ScrollView requires two taps to start scrolling

我在另一个 ScrollView 里面有一个 ScrollView。我注意到我必须点击两次才能使嵌套滚动视图开始滚动。

我尝试使用 scrollEnablednestedScrollEnabledkeyboardShouldPersistTaps="always" 等属性,但其中 none 有所帮助。

我无法提供任何实际代码,因为该项目非常大,并且滚动视图之间有多个组件。但是,基本结构类似于这样:

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

我建议您也尝试将 keyboardShouldPersistTaps='always' 放在最外面的 <ScrollView /> 组件上。根据 this GitHub issue 中的最终答案,应该可以解决它。

例如:

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