Issue regarding the header anchor #471
-
I have the following issue using vuepress (version v2.0.0-beta.26). On refresh, the page does not scroll to the anchor selected. I stay at the top of the page, and the anchor selected in the URL disappears. To sum up:
My question would be: do you have any idea why I get this behavior? Or do you know how i can investigate this issue? I try the following:
Another anomaly that I encountered (that may be linked with the anchor issue), on refresh, the sidebar disappears (it displays correctly when I navigate from the root of my website) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I ended up adding a bit of javascript code to fix my anchor issue:
{
head: [
['script', {}, `
(function() {
var hash = window.location.hash;
setTimeout(()=>{
const element = document.querySelector(hash)
const topPos = element.getBoundingClientRect().top + window.pageYOffset
window.scrollTo({
top: topPos,
behavior: 'smooth'
})
}, 100)
})();
`]
]
} Credits: |
Beta Was this translation helpful? Give feedback.
-
A related issue is created, see #693, and I make a PR #722. Also, your answer is a good workaround.👍 |
Beta Was this translation helpful? Give feedback.
A related issue is created, see #693, and I make a PR #722. Also, your answer is a good workaround.👍