Skip to content

Commit c132997

Browse files
committed
feat: NavBar 组件返回按钮新增 history.state.back 判断
1 parent 00a84c2 commit c132997

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/layout/components/NavBar.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<script setup lang="ts">
22
const route = useRoute()
33
4+
const router = useRouter()
5+
46
const title = computed(() => route.meta.title)
57
68
const showLeftArrow = computed(() => route.meta.layout?.navBar?.showLeftArrow)
79
810
function onClickLeft() {
9-
history.back()
11+
if (window.history.state?.back)
12+
history.back()
13+
else
14+
router.replace("/")
1015
}
1116
</script>
1217

0 commit comments

Comments
 (0)