createSelectorQuery()获取scroll-view 垂直滚动
createSelectorQuery()获取scroll-view 垂直滚动位置
let id = “#id” + item;
let scrollTop = that.data.scrollTop
console.log(scrollTop)
const query = this.createSelectorQuery()
query.select(id).boundingClientRect()
setTimeout(function () {
query.selectViewport().scrollOffset()
query.exec(function (res) {
console.log(res)
that.setData({
scrollTopPlay: scrollTop,
bottomHeight: res[0].height
});
})
}, 1000)
点击时获取的scrollTop 一直为0 , 我这个是在组件总调用的方法,不在组件中 可以正常获取高度