uniapp获取系统信息(屏幕高度),并设置组件高度
uni.getSystemInfo()可获取的系统信息有多种,包括:
brand | 设备品牌 |
---|---|
model | 设备型号 |
pixelRatio | 设备像素比 |
screenWidth | 屏幕宽度 |
screenHeight | 屏幕高度 |
windowWidth | 可使用窗口宽度 |
windowHeight | 可使用窗口高度 |
windowTop | 可使用窗口的顶部位置 |
windowBottom | 可使用窗口的底部位置 |
statusBarHeight | 状态栏的高度 |
navigationBarHeight | 导航栏的高度 |
getHeight(){
uni.getSystemInfo({
success: (res) => {
//获取自己需要的屏幕高度
this.swiperHeight=res.windowHeight-62
}
})
}
获取屏幕高度后动态设置容器高度
<scroll-view scroll-y="true" :style="{height:swiperHeight+'px'}">
<!-- 通过:style绑定容器高度-->