微信小程序的组件获取不到高度

let query = wx.createSelectorQuery().in(this);
query.select("#app_calendar").boundingClientRect(function (res) {
console.log("rect2", res)
if (res) {
// that.setData({
// fixedTopHeight: rect.height
// })
console.log(res.height)
}
}).exec();

后面的.in(this)代表在组件中查询,加上就好使了

你可能感兴趣的:(微信小程序,小程序)