taro ref & wx.createSeletorQuery
taro ref & wx.createSeletorQuery
https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
https://nervjs.github.io/taro/docs/ref.html
const query = wx.createSelectorQuery()
query.select('#the-id').boundingClientRect()
query.selectViewport().scrollOffset()
query.exec(function(res){
res[0].top // #the-id节点的上边界坐标
res[1].scrollTop // 显示区域的竖直滚动位置
})
HTML query selector
https://wiki.developer.mozilla.org/en-US/docs/Web/API/Element/querySelector
https://wiki.developer.mozilla.org/en-US/docs/Web/API/Element/querySelectorAll
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/12685835.html
未经授权禁止转载,违者必究!