bugfix SMHeader scroll

This commit is contained in:
2023-04-24 14:40:48 +10:00
parent 325c6a0448
commit d3776a8d3f
2 changed files with 12 additions and 9 deletions

View File

@@ -1,10 +1,8 @@
<template>
<a :href="`#${id}`" class="header">
<h3>
{{ props.text }}
<span class="hash" @click.prevent="copyAnchor">#</span>
</h3>
</a>
<h3 :id="id" class="header">
{{ props.text }}
<span class="hash" @click.prevent="copyAnchor">#</span>
</h3>
</template>
<script setup lang="ts">
@@ -56,9 +54,6 @@ const copyAnchor = () => {
<style lang="scss">
.header {
color: var(--base-color-text) !important;
text-decoration: none;
.hash {
display: none;
color: var(--primary-color);

View File

@@ -489,6 +489,14 @@ router.afterEach((to, from) => {
if (autofocusElement) {
autofocusElement.focus();
}
const hash = window.location.hash;
if (hash) {
const target = document.querySelector(hash);
if (target) {
target.scrollIntoView();
}
}
}, 10);
});