Skip to content

Commit

Permalink
Chore: Fix doc anchor bug
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed Jul 23, 2019
1 parent 9ee2fed commit 6c527f3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions examples/pages/template/component.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,14 @@
beforeRouteUpdate(to, from, next) {
next();
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;
this.renderAnchorHref();
} else {
this.goAnchor();
}
}, 100);
}
Expand Down

0 comments on commit 6c527f3

Please sign in to comment.