wxml:
<view class="usermotto" style="height:213px;" id='the-id'/>
复制代码
js:
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://developers.weixin.qq.com/miniprogram/dev/api/wx.createSelectorQuery.html