Skip to content

Commit

Permalink
fix: 修复tab页只剩一个的时候无法关闭的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 28, 2024
1 parent 0acd482 commit 0594ae9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/layout/components/Tabs/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ watch(
// 点击页签
const handleTabClick = (key: string) => {
const obj = tabsStore.tabList.find((i) => i.path === key)
obj ? router.push(obj.fullPath) : router.push(key)
obj ? router.push(obj.fullPath || obj.path) : router.push(key)
}
</script>

Expand Down
3 changes: 2 additions & 1 deletion src/stores/modules/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const storeSetup = () => {
const isActive = router.currentRoute.value.path === tabList.value[index].path
tabList.value.splice(index, 1)
if (isActive) {
router.push(tabList.value[tabList.value.length - 1].fullPath)
const lastObj = tabList.value[tabList.value.length - 1]
router.push(lastObj.fullPath || lastObj.path)
}
}

Expand Down

0 comments on commit 0594ae9

Please sign in to comment.