首页 > 其他分享 >uniapp使用uni.createSelectorQuery()获取高度为null

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

时间:2023-03-22 19:32:04浏览次数:39  
标签:uniapp 高度 createSelectorQuery height uni query data

  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 = 屏幕可用高度-顶部标题高度

标签:uniapp,高度,createSelectorQuery,height,uni,query,data
From: https://blog.51cto.com/u_15694202/6143124

相关文章