fix: scroll to hash
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user