react-native ScrollView 嵌套 FlatList滚动
作者:互联网
最近项目遇到需要使用ScrollView 嵌套 FlatList的功能,当flatList滚动时,ScrollView也在滚动,最后在github上找到了解决办法,防止忘记记录一下!!
ScrollView 嵌套 FlatList滚动,当flatList滚动时,ScrollView禁止滚动
this.state = {
enableScrollViewScroll: true,
...
}
onEnableScroll = value => {
this.setState({
enableScrollViewScroll: value,
});
};
render() {
return(
<ScrollView
scrollEnabled={this.state.enableScrollViewScroll}
>
<FlatList
onTouchStart={() => {this.onEnableScroll(false);}}
onMomentumScrollEnd={() => {this.onEnableScroll(true);}}
...
/>
...
</ScrollView>
)
}
借鉴地址:https://github.com/facebook/react-native/issues/19971
标签:...,滚动,FlatList,onEnableScroll,ScrollView,react,嵌套 来源: https://blog.csdn.net/zhizhuodewo6/article/details/112230666