使用uni.getSystemInfo 获取屏幕高度没有问题,但是获取元素高度时,高度值不准确
尝试过 this.$nextTick(function(){}) 和 setTimeOut都无法获取准确的高度值
部分代码如下
uni.getSystemInfo({
success: function(res) {
console.log(res.screenHeight)
let info = uni.createSelectorQuery().select(".columnTitle");
info.boundingClientRect(function(data) { //data - 各种参数
console.log(data.height) // 获取元素宽度
}).exec()
}
})
打印结果如下
实际盒子模型如下
有没有大佬给个解决方案