Skip to content

Commit

Permalink
Chore: Fix doc anchor bug (#16692)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun authored and island205 committed Jul 23, 2019
1 parent 9ee2fed commit e8483ac
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 e8483ac

Please sign in to comment.