fix(tabbar): 修复未匹配路由时默认选中第一个标签的问题

当当前页面路由不在标签栏配置中时,检查是否在页面栈中存在匹配路由,避免直接选中第一个标签
This commit is contained in:
feige996
2025-08-24 12:51:32 +08:00
parent 3d0cc15ac0
commit b184adc9a3

View File

@@ -40,7 +40,13 @@ const tabbarStore = reactive({
console.log('index:', index, path)
// console.log('tabbarList:', tabbarList)
if (index === -1) {
this.setCurIdx(0)
const pagesPathList = getCurrentPages().map(item => item.route.startsWith('/') ? item.route : `/${item.route}`)
// console.log(pagesPathList)
const flag = tabbarList.some(item => pagesPathList.includes(item.pagePath))
if (!flag) {
this.setCurIdx(0)
return
}
}
else {
this.setCurIdx(index)