Commit e8483acb authored by iamkun's avatar iamkun Committed by Zhi Cun

Chore: Fix doc anchor bug (#16692)

parent 9ee2fedd
...@@ -240,11 +240,14 @@ ...@@ -240,11 +240,14 @@
beforeRouteUpdate(to, from, next) { beforeRouteUpdate(to, from, next) {
next(); next();
setTimeout(() => { setTimeout(() => {
if (location.href.match(/#/g).length < 2) { const toPath = to.path;
const fromPath = from.path;
if (toPath === fromPath && to.hash) {
this.goAnchor();
}
if (toPath !== fromPath) {
document.documentElement.scrollTop = document.body.scrollTop = 0; document.documentElement.scrollTop = document.body.scrollTop = 0;
this.renderAnchorHref(); this.renderAnchorHref();
} else {
this.goAnchor();
} }
}, 100); }, 100);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment