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);
}