Skip to content

Commit 6c7375a

Browse files
iamkunoleksiikhr
authored andcommitted
Chore: Fix doc anchor bug (ElemeFE#16692)
1 parent 8460804 commit 6c7375a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

examples/pages/template/component.tpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,14 @@
240240
beforeRouteUpdate(to, from, next) {
241241
next();
242242
setTimeout(() => {
243-
if (location.href.match(/#/g).length < 2) {
243+
const toPath = to.path;
244+
const fromPath = from.path;
245+
if (toPath === fromPath && to.hash) {
246+
this.goAnchor();
247+
}
248+
if (toPath !== fromPath) {
244249
document.documentElement.scrollTop = document.body.scrollTop = 0;
245250
this.renderAnchorHref();
246-
} else {
247-
this.goAnchor();
248251
}
249252
}, 100);
250253
}

0 commit comments

Comments
 (0)