From 375cc0fd5320f83b35b8e47bc07fc21887d63f13 Mon Sep 17 00:00:00 2001 From: zsk <710162063@qq.com> Date: Thu, 7 Aug 2025 15:06:07 +0800 Subject: [PATCH] uni.removeTabBarBadge --- App.vue | 10 +++++++--- pages/person/index.vue | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/App.vue b/App.vue index f9aa300..fd89ed0 100644 --- a/App.vue +++ b/App.vue @@ -283,9 +283,13 @@ export default { text: String(res.approvePassHasNotRed), }); } else { - uni.removeTabBarBadge({ - index: 2, - }); + try { + uni.removeTabBarBadge({ + index: 2, + }); + } catch (error) { + console.log("当前页面不是 TabBar 页面,无法移除 badge"); + } } }); } diff --git a/pages/person/index.vue b/pages/person/index.vue index bf09582..b85e60e 100644 --- a/pages/person/index.vue +++ b/pages/person/index.vue @@ -764,9 +764,13 @@ export default { }); that.readed = false; } else { - uni.removeTabBarBadge({ - index: 2, - }); + try { + uni.removeTabBarBadge({ + index: 2, + }); + } catch (error) { + console.log("当前页面不是 TabBar 页面,无法移除 badge"); + } that.readed = true; } });