feat: improve hash target positioning upon initial navigation

This commit is contained in:
Justineo
2021-10-21 18:38:51 +08:00
parent 2bfe8ad8ec
commit 047867d72a
3 changed files with 24 additions and 1 deletions

View File

@@ -21,6 +21,9 @@ export default ({ app, route }) => {
setTimeout(() => {
const selector = decodeURIComponent(to.hash)
const anchor = document.querySelector(selector)
if (!anchor) {
return
}
if (anchor.tagName === 'CODE') {
target = anchor.closest('tr')