# uni.getWindowInfo()

Get window information

App H5 微信小程序 支付宝小程序 抖音小程序 快手小程序 QQ小程序 百度小程序 京东小程序 钉钉小程序 飞书小程序 元服务
(3.4.13+) (3.4.13+) (2.20.1+) x x x x x x x x x

# getWindowInfo 兼容性

HarmonyOS
HBuilderX 4.23

Return parameter description

Parameter Name Type Description Platform Difference Description
pixelRatio number Device pixel ratio
screenWidth number Screen width
screenHeight number Screen Height
windowWidth number Available window width
windowHeight number 可使用窗口高度
windowTop number 可使用窗口的顶部位置
windowBottom number The bottom position of the available window
statusBarHeight number The height of the mobile phone status bar
screenTop number The y value of the top edge of the window
safeArea object Safe area in the positive direction of vertical screen
safeAreaInsets object Inset position of safe area in the positive direction of vertical screen

Structure of safeArea

parameter type description
left Number Abscissa of the upper left corner of the safe area
right Number Abscissa of the lower right corner of the safe area
top Number The vertical coordinate of the upper left corner of the safe area
bottom Number The vertical coordinate of the lower right corner of the safe area
width Number Width of the safe area, in logical pixels
height Number The height of the safe area, in logical pixels

Structure of safeAreaInsets

parameter type description
left Number Insert position on the left side of the safe area
right Number The right caret position of the safe area
top Number 安全区顶部插入位置
bottom Number 安全区域底部插入位置

# 返回值

类型 描述
GetWindowInfoResult result

|:-|:-|:-|:-|:-:|:-| |pixelRatio|number|是|-|

|设备像素比
| |screenWidth|number|是|-|
|屏幕宽度,单位为px
| |screenHeight|number|是|-|
|屏幕高度,单位为px
| |windowWidth|number|是|-|
|可使用窗口宽度,单位为px
| |windowHeight|number|是|-|
|可使用窗口高度,单位为px
| |statusBarHeight|number|是|-|
|状态栏的高度,单位为px
| |windowTop|number|是|-|
|内容区域距离顶部的距离(同CSS变量 --window-top),单位为px
| |windowBottom|number|是|-|
|内容区域距离底部的距离(同CSS变量 --window-bottom),单位为px
| |safeArea|SafeArea|是|-|
|安全区域在屏幕中的位置信息
| |safeAreaInsets|SafeAreaInsets|是|-|
|安全区域插入位置(与屏幕边界的距离)信息
| |screenTop|number|是|-|
|窗口上边缘的 y 值,单位为px
| |cutoutArea|Array<CutoutRect>|否|-|
|挖孔、刘海区域在屏幕中的位置信息
|