English
Listen for window size change events
1.6.0 Added
Platform Difference Description
| App | HarmonyOS Next | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 抖音小程序 | 飞书小程序 | QQ小程序 | 元服务 | 小红书小程序 |
|---|---|---|---|---|---|---|---|---|---|---|
| √ | HBuilderX 4.25 | √ | √ | x | x | x | √ | √ | x | x |
CALLBACK parameter description
| Attribute | Type | Description |
|---|---|---|
| size | Object | The size of the changed window, the unit is px, {windowWidth,windowHeight} |
code example
const windowResizeCallback = (res) => {
console.log('变化后的窗口宽度=' + res.size.windowWidth)
}
uni.onWindowResize(windowResizeCallback)
TIPS
Cancel listening window size change event
1.6.0 Added
Explanation of Platform Differences
| App | HarmonyOS Next | H5 | 微信小程序 | 支付宝小程序 | 百度小程序 | 抖音小程序 | 飞书小程序 | 元服务 | 小红书小程序 |
|---|---|---|---|---|---|---|---|---|---|
| √ | HBuilderX 4.31 | √ | √ | x | x | x | √ | x | x |
Tips
CALLBACK is the CALLBACK passed in when calling uni.onWindowResizecode example
uni.offWindowResize(windowResizeCallback)