Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如何在React Native中获取页面的滚动值_React Native - Fatal编程技术网

React native 如何在React Native中获取页面的滚动值

React native 如何在React Native中获取页面的滚动值,react-native,React Native,我正在尝试获取页面的滚动值,以便能够在滚动后启用特定组件 <ScrollView stickyHeaderIndices={[0]} showsVerticalScrollIndicator={false} onScroll={this.handleScroll} scrollEventThrottle={16} > {child1} {Child 2} </

我正在尝试获取页面的滚动值,以便能够在滚动后启用特定组件

 <ScrollView
          stickyHeaderIndices={[0]}
          showsVerticalScrollIndicator={false}
          onScroll={this.handleScroll}
          scrollEventThrottle={16}
        >
     {child1}
     {Child 2}
 </ScrollView>


handleScroll = (event: Object) => {
  console.log(event.nativeEvent.contentOffset.y);
},

{child1}
{Child 2}
handleScroll=(事件:对象)=>{
log(event.nativeEvent.contentOffset.y);
},
此处未在事件对象中找到nativeEvent。那么有没有其他方法呢?

您是否尝试过以下方法:

<ScrollView
          stickyHeaderIndices={[0]}
          showsVerticalScrollIndicator={false}
          onScroll={this.handleScroll.bind(this)}
          scrollEventThrottle={16}
        >
     {child1}
     {Child 2}
</ScrollView>
handleScroll({ nativeEvent }) {
  console.log(nativeEvent.contentOffset.y);
}