tabbar bug

This commit is contained in:
BAKEYi 2026-05-27 16:38:14 +08:00
parent 1d611bee0b
commit a9455ce98d
1 changed files with 29 additions and 3 deletions

View File

@ -69,8 +69,34 @@ export default {
};
},
computed: {
// Vuex
...mapState(['currentTabIndex', 'messageNum'])
//
...mapState(['messageNum']),
// ========= =========
// Vuex
currentTabIndex() {
try {
//
const pages = getCurrentPages();
if (pages && pages.length > 0) {
//
const currentPage = pages[pages.length - 1];
//
const currentPath = '/' + (currentPage.route || currentPage.__route__);
// tabbarList
const index = this.tabbarList.findIndex(item => item.pagePath === currentPath);
if (index !== -1) {
return index;
}
}
// Vuex
return this.$store.state.currentTabIndex || 0;
} catch (e) {
return this.$store.state.currentTabIndex || 0;
}
}
// =================================================
},
watch: {
// tabbarList
@ -153,7 +179,7 @@ export default {
const idx = parseInt(index, 10);
if (isNaN(idx) || !this.tabbarList[idx]) return;
//
// Vuex
this.setCurrentTabIndex(idx);
//