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
}
相关推荐
alphaair4 小时前
【一步步开发AI运动APP】十、微调优化内置运动分析器,灵活适配不同的应用场景
uni-app·ai运动·ai运动识别·ai健身·ai体测·ai运动app·ai运动检测·工会云上运动会·ai人体检测·ai姿态识别
moxiaoran57536 小时前
uni-app学习笔记二十三--交互反馈showToast用法
笔记·学习·uni-app
Angindem15 小时前
从零搭建uniapp项目
前端·vue.js·uni-app
Bug从此不上门20 小时前
【无标题】
前端·javascript·uni-app·vue
耶啵奶膘1 天前
uniapp+vue2解构赋值和直接赋值的优缺点
uni-app
疯狂的沙粒1 天前
uni-app 项目支持 vue 3.0 详解及版本升级方案?
前端·vue.js·uni-app
Jiaberrr1 天前
uniapp Vue2 获取电量的独家方法:绕过官方插件限制
前端·javascript·uni-app·plus·电量
^Rocky1 天前
uniapp 对接腾讯云IM群公告功能
uni-app·腾讯云
段旭涛1 天前
uniapp 设置手机不息屏
前端·uni-app
疯狂的沙粒1 天前
在web-view 加载的本地及远程HTML中调用uniapp的API及网页和vue页面是如何通讯的?
前端·uni-app·html