From d9f882140728f3e6ebcb69b42d22243402fbc83a Mon Sep 17 00:00:00 2001 From: shutao Date: Thu, 23 May 2024 17:05:44 +0800 Subject: [PATCH] =?UTF-8?q?update=20theme-change.uvue=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B3=A8=E9=94=80=E7=9B=91=E5=90=AC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/theme-change/theme-change.uvue | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pages/API/theme-change/theme-change.uvue b/pages/API/theme-change/theme-change.uvue index ab118218..0b7a168b 100644 --- a/pages/API/theme-change/theme-change.uvue +++ b/pages/API/theme-change/theme-change.uvue @@ -45,11 +45,13 @@ }, methods: { bindOsThemeChange(): number { + //注册osTheme变化监听 return uni.onOsThemeChange(function(res: OsThemeChangeResult) { this.osTheme = res.osTheme }) }, bindAppThemeChange(): number { + //注册appTheme变化监听 return uni.onAppThemeChange(function(res: AppThemeChangeResult) { this.appTheme = res.appTheme }) @@ -84,6 +86,11 @@ }) this.osThemeChangeId = bindOsThemeChange() this.appThemeChangeId = bindAppThemeChange() + }, + onUnload() { + //注销监听 + uni.offAppThemeChange(this.appThemeChangeId) + uni.offOsThemeChange(this.osThemeChangeId) } } -- GitLab