react native ScrollView滚动不起作用
来源:互联网 发布:麦德斯 米科尔森 知乎 编辑:程序博客网 时间:2024/06/10 09:34
在做页面初始化时, 想ScrollView跳转到指定的位置,结果发现代码执行了,却没有跳到指定的位置,代码如下。
componentDidMount(){
scrollView.scrollTo({x: 0, y: 0, animated: true})
}
经过大量查找各种资料,发现在ScrollView初始化时有个动画效果,只有动画结束了,调用scrollView.scrollTo才有效果,官方资料没有说明这点
我们可以这样做,在componentDidMount()里加一个延时操作就可以了。其实Flatlist也有同样的问题。解决办法一样
componentDidMount() { this.fristTime = setTimeout(() => { ScrollView.scrollTo({x: 0, y: 0, animated: true}) }, 0) }
阅读全文
1 0
- react native ScrollView滚动不起作用
- React Native scrollview滚动事件
- react native scrollview 滚动停止事件
- react-native ScrollView触摸与滚动事件
- react native scrollview深入详解触摸滚动事件
- react native scrollview深入详解触摸滚动事件
- react native Scrollview在某些时候滚动无效
- React Native之 ScrollView
- react-native之ScrollView
- React Native 之 ScrollView
- React Native 之 ScrollView使用
- React native (6) scrollview listview
- react native ScrollView 使用详解
- React Native ScrollView 常用属性
- React Native 之 ScrollView使用
- 浅谈react native中的ScrollView
- React-native ListView不滚动
- React Native 滚动页面置顶
- Linux tcpdump命令详解
- 前端跨域请求原理及实践
- Babel简介
- Java 3DES 加密
- python socket编程基础(思维导图)
- react native ScrollView滚动不起作用
- [Java面试三]JavaWeb基础知识总结
- Linux中断
- pbr制作
- cookie、session、webStorage(localStrorage、sessionStorage)
- 十一周项目一
- Java RSA 加密
- for与for in的区别 -记录
- OpenMp之sections用法