gpt4 book ai didi

react-native - 如何在 react 原生平面列表中滚动到顶部后调用函数

转载 作者:行者123 更新时间:2023-12-04 10:54:18 24 4
gpt4 key购买 nike

函数 MyComponent() {
const flatListRef = React.useRef()

const toTop = () => {
// use current
flatListRef.current.scrollToOffset({ animated: true, offset: 0 })
}

return (
<FlatList
ref={flatListRef}
data={...}
...
/>
)

}

最佳答案

尝试这个:

onScrollToTop功能

关于react-native - 如何在 react 原生平面列表中滚动到顶部后调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59301773/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com