滚动到 ScrollView 的顶部 [英] Scroll to top of ScrollView

查看:34
本文介绍了滚动到 ScrollView 的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在按下按钮时滚动到 ScrollView 的顶部?

Is there a way to scroll to the top of a ScrollView in response to a button press?

我可以强制重新渲染整个页面,但这似乎非常低效.

I can force a re-render of the whole page but that seems very inefficient.

推荐答案

您可以运行 ScrollView 的scrollTo"方法.查看来源.

You can run the "scrollTo" method of the ScrollView. Check out the source.

您可以通过设置 ref 属性并使用 this.refs 来获取对 ScrollView 组件的引用,如下所述:https://facebook.github.io/react/docs/more-about-refs.html

You can get reference the ScrollView component by setting ref property and using this.refs as described here: https://facebook.github.io/react/docs/more-about-refs.html

这篇关于滚动到 ScrollView 的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆