Explorar o código

Chore: Fix doc anchor bug (#16692)

iamkun %!s(int64=6) %!d(string=hai) anos
pai
achega
e8483acb08
Modificáronse 1 ficheiros con 6 adicións e 3 borrados
  1. 6 3
      examples/pages/template/component.tpl

+ 6 - 3
examples/pages/template/component.tpl

@@ -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);
     }