From 0fc77b9efb31a154e1c06e3d95dc920edac61d6d Mon Sep 17 00:00:00 2001 From: shutao Date: Thu, 30 May 2024 19:09:30 +0800 Subject: [PATCH] =?UTF-8?q?theme.md=20=E6=B7=BB=E5=8A=A0example=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api/theme.md | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/docs/api/theme.md b/docs/api/theme.md index 6e0b96cc..cbb1cfcf 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) +``` -- GitLab