wx.createSelectorQuery().selectViewpo
发布于 5 年前 作者 guiying46 13573 次浏览 来自 问答

const query = wx.createSelectorQuery()

query.select(id).boundingClientRect()

setTimeout(function () {

query.selectViewport().scrollOffset()

query.exec(function (res) {

console.log(res)

that.setData({

scrollTopPlay: res[1].scrollTop,

bottomHeight: res[0].height

});

})

}, 400)

获取到的scrollTop的值一直是0

 有没有大神指点一下啊

2 回复

scrollTop返回的是scroll-view内的滚动的位置,你要在scroll-view内滑动一下scrollTop才不是0

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)

回到顶部