- 添加定时器后获取
setTimeout(()=>{
const query = uni.createSelectorQuery().in(this);
query.select('.content').boundingClientRect((data)=>{
console.log('data.height',data.height);
this.contentHeight = data.height;
}).exec();
},100)
- 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