On this page
Window
onWindowResize
TIP
The API usage is as follows: wx.onWindowResize(function listener)
- Functional description: Listen to window size change events
- Parameters and descriptions: function listener, the listener function for window size change events.
| Properties | Type |
|---|---|
| size | Object |
- size Structure properties
Structure properties Type Description windowWidth number The changed window width, in px windowHeight number The changed window height, in px
offWindowResize
TIP
The API usage is as follows: wx.offWindowResize(function listener)
- Functional description: Remove the listener function for the window size change event.
- Parameters and descriptions: Function listener, the listener function passed in by onWindowResize. If this parameter is not passed, all listeners will be removed.
js
const listener = function (res) { console.log(res) }
wx.onWindowResize(listener)
wx.offWindowResize(listener) // Pass the same function object used for listening.