fix(tabbar): 修复设置tabbar角标时的潜在越界问题

在设置tabbar角标前添加数组越界检查,防止当idx超出tabbarList范围时报错
This commit is contained in:
feige996
2025-08-24 16:19:08 +08:00
parent b05e0b8ec3
commit eafd3a9f30
2 changed files with 12 additions and 1 deletions

View File

@@ -36,7 +36,9 @@ const tabbarStore = reactive({
uni.setStorageSync('app-tabbar-index', idx)
},
setTabbarItemBadge(idx: number, badge: CustomTabBarItemBadge) {
tabbarList[idx].badge = badge
if (tabbarList[idx]) {
tabbarList[idx].badge = badge
}
},
setAutoCurIdx(path: string) {
const index = tabbarList.findIndex(item => item.pagePath === path)