uniapp可视范围高度 - 用户屏幕可操作的屏幕高度 - 适用于APP、H5@公众号、纯H5@Chrome

可视范围高度

let heightPx = uni.getWindowInfo().windowHeight + uni.getWindowInfo().windowTop

官方手册

uni.getWindowInfo() | uni-app官网uni-app,uniCloud,serverless,uni.getWindowInfo()https://uniapp.dcloud.net.cn/api/system/getWindowInfo.html

实测数据

bash 复制代码
============================
uni.getWindowInfo() >> APP-安卓真机实测
============================
{
    "pixelRatio": 3,
    "screenWidth": 360,
    "screenHeight": 640,
    "windowWidth": 360,
    "windowHeight": 640,
    "statusBarHeight": 24,
    "safeArea": {
        "left": 0,
        "right": 360,
        "top": 24,
        "bottom": 640,
        "width": 360,
        "height": 616
    },
    "safeAreaInsets": {
        "top": 24,
        "right": 0,
        "bottom": 0,
        "left": 0
    },
    "windowTop": 0,
    "windowBottom": 0,
    "screenTop": 0
}

============================
uni.getWindowInfo() >> 纯H5 - 非公众号
============================
{
    "windowTop": 44,
    "windowBottom": 0,
    "windowWidth": 390,
    "windowHeight": 800,
    "pixelRatio": 3.0000001192092896,
    "screenWidth": 390,
    "screenHeight": 844,
    "statusBarHeight": 0,
    "safeArea": {
        "left": 0,
        "right": 390,
        "top": 0,
        "bottom": 844,
        "width": 390,
        "height": 844
    },
    "safeAreaInsets": {
        "top": 0,
        "right": 0,
        "bottom": 0,
        "left": 0
    },
    "screenTop": 44
}


============================
uni.getWindowInfo() >> H5公众号 - 苹果机iPhone13Pro
============================
{
    "windowTop": 44,
    "windowBottom": 0,
    "windowWidth": 390,
    "windowHeight": 710,
    "pixelRatio": 3.0000001192092896,
    "screenWidth": 390,
    "screenHeight": 753,
    "statusBarHeight": 0,
    "safeArea": {
        "left": 0,
        "right": 390,
        "top": 0,
        "bottom": 720,
        "width": 390,
        "height": 720
    },
    "safeAreaInsets": {
        "top": 0,
        "right": 0,
        "bottom": 34,
        "left": 0
    },
    "screenTop": 43
}

============================
uni.getWindowInfo() >> H5公众号 - 安卓机Nexus 6
============================
{
    "windowTop": 44,
    "windowBottom": 0,
    "windowWidth": 412,
    "windowHeight": 620,
    "pixelRatio": 3.0000001192092896,
    "screenWidth": 412,
    "screenHeight": 664,
    "statusBarHeight": 0,
    "safeArea": {
        "left": 0,
        "right": 412,
        "top": 0,
        "bottom": 664,
        "width": 412,
        "height": 664
    },
    "safeAreaInsets": {
        "top": 0,
        "right": 0,
        "bottom": 0,
        "left": 0
    },
    "screenTop": 44
}
相关推荐
遗憾随她而去.1 小时前
uniapp 中使用路由导航守卫,进行登录鉴权
前端·uni-app
牧杉-惊蛰5 小时前
uniapp微信小程序css中background-image失效问题
css·微信小程序·uni-app
Little_Code13 小时前
uniapp 使用ffmpeg播放rtsp
ffmpeg·uni-app·rtsp
儿歌八万首14 小时前
uniapp 和原生插件交互
uni-app·交互
前端 贾公子1 天前
在移动端使用 Tailwind CSS (uniapp)
前端·uni-app
源码_V_saaskw10 天前
宇鹿家政服务系统小程序ThinkPHP+UniApp
微信小程序·小程序·uni-app·微信公众平台
xw510 天前
支付宝小程序IDE版本迭代异常
uni-app·支付宝
!win !10 天前
支付宝小程序IDE版本迭代异常
uni-app·支付宝小程序
xw510 天前
抖音小程序支付错误码141211
uni-app·抖音小程序
好好的哦10 天前
抖音小程序支付错误码141211
小程序·uni-app