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,问题可能出现在页面数据加载未完成就执行以上代码。
wxml元素高度获取技巧
1万+

被折叠的 条评论
为什么被折叠?



