HarmonyOS 关于在uniapp中api不兼容bug?

在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()
  }
})
阅读 472
1 个回答

示例参考:

<template>
  <view class="nav-bar"></view>
  </template>
uni.getSystemInfo({
  success(res) {
    console.log(res,'res',this);
    let node = uni.createSelectorQuery().select('.nav-bar');
    node.boundingClientRect(data => {
      console.log(JSON.stringify(data))
    }).exec()
  }
})

这样写是可以获取的,是在mounted那个阶段调用的。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进