我不敢再看你 多一眼都是痛
将要获取的元素id 或者class传入即可
文档地址https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createSelectorQuery.html
// 获取元素高度
getPaddingTopFn() {
let that = this;
wx.createSelectorQuery().selectAll('.header').boundingClientRect(function (rects) {
that.setData({
console.log(rects)
})
}).exec();
},