React原生ScrollView scrollTo无法正常工作



这是我的函数:

const scrollToDown = () =>
positionRef.current.scrollTo({x: -100, y: -100, animated: true});

当调用这个函数时,我希望屏幕向下滚动一点,但它一直滚动到屏幕顶部。

有什么建议吗?

你可以试试这个

const scrollRef = useRef();
const onPressTouch = () => {
scrollRef.current.scrollTo({
y: 100,
animated: true,
});
}
<ScrollView ref={scrollRef}>
....
</ScrollView>

最新更新