Bläddra i källkod

fix: scroll back to top when tab switch (#3498). resolve #3490

xachary 1 år sedan
förälder
incheckning
d709dd67b5
1 ändrade filer med 2 tillägg och 3 borttagningar
  1. 2 3
      src/router/guard/index.ts

+ 2 - 3
src/router/guard/index.ts

@@ -101,11 +101,10 @@ function createScrollGuard(router: Router) {
     return /^#/.test(href);
   };
 
-  const body = document.body;
-
   router.afterEach(async (to) => {
     // scroll top
-    isHash((to as RouteLocationNormalized & { href: string })?.href) && body.scrollTo(0, 0);
+    isHash((to as RouteLocationNormalized & { href: string })?.href) &&
+      document.querySelector('.vben-layout-content')?.scrollTo(0, 0);
     return true;
   });
 }