在uniapp适配HarmonyOS调用api uni.getSystemInfo/uni.createQuerySelector获取的元素节点为空:
uni.getSystemInfo({
success(res) {
console.log(res, 'res', this);
that.sysTemHeight = that.pxToRpx(res.windowTop);
console.log('sysTemheight');
uni.createSelectorQuery().select('.nav-bar').boundingClientRect(data => {
// height = screenHeight - data.height
that.navHeight = that.pxToRpx(data.height)
}).exec()
}
})
示例参考:
这样写是可以获取的,是在mounted那个阶段调用的。