mpx.getWindowInfo()
获取窗口信息
支持情况: 微信、支付宝、web、RN
参数
Object
| 属性 | 类型 | 说明 | 支付宝 | RN | web | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| pixelRatio | number | 设备像素比 | ✓ | ✓ | ✓ | |||||||||||||||||||||
| screenWidth | number | 屏幕宽度,单位px | ✓ | ✓ | ✓ | |||||||||||||||||||||
| screenHeight | number | 屏幕高度,单位px | ✓ | ✓ | ✓ | |||||||||||||||||||||
| windowWidth | number | 可使用窗口宽度,单位px | ✓ | ✓ | ✓ | |||||||||||||||||||||
| windowHeight | number | 可使用窗口高度,单位px | ✓ | ✓ | ✓ | |||||||||||||||||||||
| statusBarHeight | number | 状态栏的高度,单位px | ✓ | ✓ | ✗ | |||||||||||||||||||||
safeArea 结构属性:
| ||||||||||||||||||||||||||
| screenTop | number | 窗口上边缘的y值 | ✓ | ✓ | ✗ | |||||||||||||||||||||
示例代码
js
const deviceInfo = mpx.getDeviceInfo()
console.log(deviceInfo.abi)
console.log(deviceInfo.benchmarkLevel)
console.log(deviceInfo.brand)
console.log(deviceInfo.model)
console.log(deviceInfo.platform)
console.log(deviceInfo.system)