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
}
相关推荐
洗发水很好用6 小时前
uniApp打包H5发布到服务器(docker)
uni-app
YUJIAN。7 小时前
使用uniapp开发微信小程序-框架搭建
微信小程序·小程序·uni-app
还这么多错误?!16 小时前
uniapp微信小程序,使用fastadmin完成一个一键获取微信手机号的功能
微信小程序·小程序·uni-app
IT 前端 张16 小时前
Uniapp 手机基座调试App 打包成Apk文件,并上传到应用商店
uni-app
User_undefined16 小时前
uniapp Native.js原生arr插件服务发送广播到uniapp页面中
android·javascript·uni-app
web1350858863516 小时前
uniapp小程序使用webview 嵌套 vue 项目
vue.js·小程序·uni-app
麦兜*16 小时前
轮播图带详情插件、uniApp插件
前端·javascript·uni-app·vue
veminhe16 小时前
uni-app使用组件button遇到的问题
uni-app·vue
m0_7482400216 小时前
uniapp跨平台开发---webview调用app方法
uni-app
407指导员17 小时前
uniapp 微信小程序 页面部分截图实现
微信小程序·小程序·uni-app