监听滚动条位置 - 小程序
作者:
侯工 | 来源:发表于
2019-04-16 19:05 被阅读0次更新前:
pageScrollToBottom: function () {
wx.createSelectorQuery().select('#the-id').boundingClientRect(function (rect) {
// 使页面滚动到底部
wx.pageScrollTo({
scrollTop: rect.bottom
})
}).exec()
}
更新后:
pageScrollToBottom: function () {
const query = wx.createSelectorQuery()
query.select('#the-id').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec(function (res) {
res[0].top // #the-id节点的上边界坐标
res[1].scrollTop // 显示区域的竖直滚动位置
})
}
本文标题:监听滚动条位置 - 小程序
本文链接:https://www.haomeiwen.com/subject/uidiwqtx.html
网友评论