wxml中:<view id='getheight'></view>
js中:
var query = wx.createSelectorQuery();
query.select('#getheight').boundingClientRect()
query.exec(function (res) {
//console.log(res);
console.log(res[0].height);
})
若报错:Cannot read property 'height' of null,问题可能出现在页面数据加载未完成就执行以上代码。