本文主要是介绍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
实测数据
============================
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
}
这篇关于uniapp可视范围高度 - 用户屏幕可操作的屏幕高度 - 适用于APP、H5@公众号、纯H5@Chrome的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!