Skip to content

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.
PropertiesType
sizeObject
  • size Structure properties
    Structure propertiesTypeDescription
    windowWidthnumberThe changed window width, in px
    windowHeightnumberThe 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.