小程序-获取view高度

xiaoxiao2021-02-28  41

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,问题可能出现在页面数据加载未完成就执行以上代码。

转载请注明原文地址: https://www.6miu.com/read-2614071.html

最新回复(0)