## uni.setAppTheme(options) @setapptheme ```uts uni.setAppTheme({ theme: "auto", success: function() { console.log("设置appTheme为", value, "成功") }, fail: function(e: IAppThemeFail) { console.log("设置appTheme为", value, "失败,原因:", e.errMsg) } }) ``` ## uni.onOsThemeChange(callback) @onosthemechange ```uts //callbackId 用于注销监听 val callbackId = uni.onOsThemeChange((res: OsThemeChangeResult)=> { console.log("onOsThemeChange---", res.osTheme) }) ``` **注意:** + android 平台 android版本 10 开始支持深色模式主题 `dark`,低于10不支持深色模式主题 ## uni.offOsThemeChange(id) @offosthemechange ```uts val callbackId = uni.onOsThemeChange((res: OsThemeChangeResult)=> { console.log("onOsThemeChange---", res.osTheme) }) ... ... //注销监听 uni.offOsThemeChange(callbackId) ``` ## uni.onAppThemeChange(callback) @onappthemechange ```uts //callbackId 用于注销监听 val callbackId = uni.onAppThemeChange((res: AppThemeChangeResult) => { console.log("onAppThemeChange", res.appTheme) }) ``` ## uni.offAppThemeChange(id) @offappthemechange ```uts val callbackId = uni.onAppThemeChange((res: AppThemeChangeResult) => { console.log("onAppThemeChange", res.appTheme) }) ... ... //注销监听 uni.offAppThemeChange(this.appThemeChangeId) ```