[英]React-native Flatlist auto scroll
我在 react native 中有一个平面列表,其中包含展开和折叠的项目(就像下拉菜单一样),所以每当单击项目展开时,如果项目内容在屏幕中溢出。我想滚动项目以便它的内容完全可见。 我该如何实施?
您可以使用measure
获取元素的偏移量,然后使用scrollToOffset
<Component ref="myComponent />
// Print component dimensions to console
this.refs.myComponent.measure( (fx, fy, width, height, px, py) => {
console.log('Component width is: ' + width)
console.log('Component height is: ' + height)
console.log('X offset to frame: ' + fx)
console.log('Y offset to frame: ' + fy)
console.log('X offset to page: ' + px)
console.log('Y offset to page: ' + py)
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.