0
点赞
收藏
分享

微信扫一扫

uniapp使用uni.createSelectorQuery()获取高度为null

  1. 添加定时器后获取

setTimeout(()=>{
  const query = uni.createSelectorQuery().in(this);
  query.select('.content').boundingClientRect((data)=>{
    console.log('data.height',data.height);
    this.contentHeight = data.height;
  }).exec();
},100)

  1. dom渲染后再获取

this.$nextTick(()=>{
  setTimeout(()=>{
  const query = uni.createSelectorQuery().in(this);
  query.select('.content').boundingClientRect((data)=>{
    console.log('data.height',data.height);
    this.contentHeight = data.height;
  }).exec();
},100)
})

元素节点操作uni.createSelectorQuery(OBJECT)

获取元素节点的height高度width宽度top顶部

uni.createSelectorQuery()

异步获取系统信息uni.getSystemInfo(OBJECT)

success返回,常用的属性有:windowWidth可使用窗口宽度、screenWidth屏幕宽度、statusBarHeight手机状态栏高度

uni.getSystemInfo()


上面是标题 下面列表占全部高度的话可以用 listHeight = 屏幕可用高度-顶部标题高度

举报

相关推荐

0 条评论