From b8e47f139524433120d60bc91f89841a48b537f9 Mon Sep 17 00:00:00 2001 From: puzvv <1@> Date: Sun, 21 Dec 2025 02:26:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=88=87=E6=8D=A2=E6=97=B6?= =?UTF-8?q?=E6=80=BB=E6=98=AF=E6=98=BE=E7=A4=BA=E6=96=B0=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E6=9C=80=E4=B8=8A=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/router/index.ts b/src/router/index.ts index 3f6a9c3..76c6d2c 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -113,6 +113,14 @@ const allRoutes = [...routes, ...extraRoutes]; const router = createRouter({ history: createWebHashHistory(), routes: allRoutes, + scrollBehavior(to, from, savedPosition) { + // 如果有保存的位置(浏览器前进/后退),则使用保存的位置 + if (savedPosition) { + return savedPosition; + } + // 否则滚动到顶部 + return { top: 0 }; + }, }); export default router;