From 42f4ec16735b4a2bbcb41ae7f1eb99acde99e65f Mon Sep 17 00:00:00 2001 From: Justineo Date: Wed, 20 Oct 2021 10:24:04 +0800 Subject: [PATCH] fix: fix scroll timing --- app/router.scrollBehavior.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/router.scrollBehavior.js b/app/router.scrollBehavior.js index 05b09d2..8abe156 100644 --- a/app/router.scrollBehavior.js +++ b/app/router.scrollBehavior.js @@ -1,6 +1,13 @@ -export default function scrollBehavior (to) { +function timeout (t) { + return new Promise(resolve => { + setTimeout(resolve, t) + }) +} + +export default async function scrollBehavior (to) { if (to.hash) { // scroll to anchor by returning the selector + await timeout(0) return { selector: decodeURIComponent(to.hash), offset: {