From 42c4f29b10e59cfc6fad067a5b803c9975ca340d Mon Sep 17 00:00:00 2001 From: Eiinu Date: Sun, 4 Feb 2024 16:30:57 +0800 Subject: [PATCH] fix(site): add router scrollBehavior (#2914) --- src/sites/mobile/router.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sites/mobile/router.ts b/src/sites/mobile/router.ts index 6655dfa086..882e1a1fb5 100644 --- a/src/sites/mobile/router.ts +++ b/src/sites/mobile/router.ts @@ -50,6 +50,14 @@ routes.push({ const router = createRouter({ history: createWebHashHistory(), + scrollBehavior(to, from, savedPosition) { + // 始终滚动到顶部 + if (savedPosition) { + return savedPosition; + } else { + return { top: 0 }; + } + }, routes });