fix: tabbar 2个BUG

This commit is contained in:
菲鸽
2024-05-11 11:32:34 +08:00
parent d6c6022a18
commit 7271f3c618
3 changed files with 9 additions and 5 deletions

View File

@@ -34,4 +34,8 @@ function selectTabBar({ value: index }: { value: number }) {
tabbarStore.setCurIdx(index)
uni.switchTab({ url })
}
onLoad(() => {
// 解决原生 tabBar 未隐藏导致有2个 tabBar 的问题
uni.hideTabBar()
})
</script>

View File

@@ -13,9 +13,13 @@ export const tabbarList = [
},
]
/**
* tabbar 状态,增加 storageSync 保证刷新浏览器时在正确的 tabbar 页面
*/
export const tabbarStore = reactive({
curIdx: 0,
curIdx: uni.getStorageSync('curIdx') || 0,
setCurIdx(idx: number) {
this.curIdx = idx
uni.setStorageSync('curIdx', idx)
},
})