提交 d9f88214 编写于 作者: shutao-dc's avatar shutao-dc

update theme-change.uvue 添加注销监听逻辑

上级 5fbfda0d
......@@ -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)
}
}
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册