From 9a2bb3ba61d653bf2ed75c19c8ee664accade482 Mon Sep 17 00:00:00 2001 From: tj <1378534974@qq.com> Date: 星期一, 17 三月 2025 16:43:30 +0800 Subject: [PATCH] 关于我们跳转到首页锚点 --- src/router/index.ts | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index e84d344..dfce3e0 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -13,7 +13,16 @@ const router = createRouter({ history: createWebHistory(), - routes + routes, + scrollBehavior(to, from, savedPosition) { + if (to.hash) { + return { + el: to.hash, + behavior: 'smooth' + }; + } + return savedPosition || { top: 0 }; + } }); export default router; -- Gitblit v1.9.3