fix: scroll to hash

This commit is contained in:
skytek_xinliang
2026-09-23 17:51:35 +08:00
parent 92c5163334
commit 0727a803c0
5 changed files with 28 additions and 5 deletions
@@ -1,5 +1,7 @@
<script setup lang="ts">
withDefaults(
import { useRouter } from "vue-router";
const props = withDefaults(
defineProps<{
title: string;
backTo?: string;
@@ -8,6 +10,17 @@ withDefaults(
backTo: "/",
},
);
const router = useRouter();
function handleBack() {
if (window.history.state?.back === props.backTo) {
router.back();
return;
}
router.push(props.backTo);
}
</script>
<template>
@@ -18,8 +31,8 @@ withDefaults(
color="primary"
prepend-icon="mdi-arrow-left"
rounded="pill"
:to="backTo"
variant="outlined"
@click="handleBack"
>
返回
</v-btn>