diff --git a/docs/api/theme.md b/docs/api/theme.md index 6e0b96cc5cf631282a8799377dedfc6361a3c916..cbb1cfcf1b036dc396a5cdf565d479c2d8fe1387 100644 --- a/docs/api/theme.md +++ b/docs/api/theme.md @@ -8,7 +8,17 @@ - +```uts +uni.setAppTheme({ + theme: "auto", + success: function() { + console.log("设置appTheme为", value, "成功") + }, + fail: function(e: IAppThemeFail) { + console.log("设置appTheme为", value, "失败,原因:", e.errMsg) + } +}) +``` @@ -22,7 +32,12 @@ - +```uts +//callbackId 用于注销监听 +val callbackId = uni.onOsThemeChange((res: OsThemeChangeResult)=> { + console.log("onOsThemeChange---", res.osTheme) +}) +``` @@ -39,7 +54,15 @@ - +```uts +val callbackId = uni.onOsThemeChange((res: OsThemeChangeResult)=> { + console.log("onOsThemeChange---", res.osTheme) +}) +... +... +//注销监听 +uni.offOsThemeChange(callbackId) +``` @@ -53,7 +76,12 @@ - +```uts +//callbackId 用于注销监听 +val callbackId = uni.onAppThemeChange((res: AppThemeChangeResult) => { + console.log("onAppThemeChange", res.appTheme) +}) +``` @@ -67,7 +95,15 @@ - +```uts +val callbackId = uni.onAppThemeChange((res: AppThemeChangeResult) => { + console.log("onAppThemeChange", res.appTheme) +}) +... +... +//注销监听 +uni.offAppThemeChange(this.appThemeChangeId) +```