From e782c4cb86dbb8ff294d0670e171692651618a0e Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 21 Jul 2020 16:57:11 -0400 Subject: [PATCH] fix: decode hash before selecting --- src/client/app/router.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/app/router.ts b/src/client/app/router.ts index db3c381aecab..8b4b678ecde0 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -64,7 +64,7 @@ export function createRouter( nextTick(() => { if (targetLoc.hash && !scrollPosition) { const target = document.querySelector( - targetLoc.hash + decodeURIComponent(targetLoc.hash) ) as HTMLElement if (target) { scrollTo(target, targetLoc.hash) @@ -150,7 +150,7 @@ function scrollTo(el: HTMLElement, hash: string, smooth = false) { const pageOffset = document.getElementById('app')!.offsetTop const target = el.classList.contains('.header-anchor') ? el - : document.querySelector(hash) + : document.querySelector(decodeURIComponent(hash)) if (target) { const targetTop = (target as HTMLElement).offsetTop - pageOffset - 15 // only smooth scroll if distance is smaller than screen height.