震惊!封装了一个组件,使用wx.createSelectorQuery().selectAll().boundingClientRect()获取到的居然是个空数组!?
解决方法出人意料,令人唏嘘,小编得知后倒吸一口凉气,当场说不出话!
在组件中注意加上.in(this)即可
const query = wx.createSelectorQuery().in(this); query.selectAll(".area-item").boundingClientRect((rect) => { console.log(rect); }).exec();