小程序应用级事件wx.onThemeChange

wx.onThemeChange(function callback)

监听系统主题改变事件。该事件与 App.onThemeChange 的回调时机一致。

基础库 2.11.0 开始支持,低版本需做兼容处理。
小程序插件:不支持

参数

function callback

系统主题改变事件的回调函数

参数

Object res
属性 类型 说明
theme string 系统当前的主题,取值为`light`或`dark`
合法值 说明
dark 深色主题
light 浅色主题

注意

  • 只有在全局配置"darkmode": true时才会触发此事件。

分类小程序生命周期相关推荐:

小程序生命周期wx.getLaunchOptionsSync 小程序生命周期wx.getEnterOptionsSync 小程序应用级事件wx.onUnhandledRejection 小程序应用级事件wx.onThemeChange 小程序应用级事件wx.onPageNotFound 小程序应用级事件wx.onError 小程序应用级事件wx.onAudioInterruptionEnd 小程序应用级事件wx.onAudioInterruptionBegin 小程序应用级事件wx.onAppShow 小程序应用级事件wx.onAppHide 小程序应用级事件wx.offUnhandledRejection 小程序应用级事件wx.offThemeChange 小程序应用级事件wx.offPageNotFound 小程序应用级事件wx.offError 小程序应用级事件wx.offAudioInterruptionEnd 小程序应用级事件wx.offAudioInterruptionBegin 小程序应用级事件wx.offAppShow 小程序应用级事件wx.offAppHide