Skip to content

Commit

Permalink
Chore: Fix doc anchor bug (ElemeFE#16692)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun authored and lzq4047 committed May 22, 2020
1 parent 8a7c014 commit e0306de
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 e0306de

Please sign in to comment.