| 12345678910111213141516 |
- import { useRouter } from 'vue-router';
- /**
- * vue路由跳转之后页面停留在上一个浏览页面位置不会回到顶部
- */
- export function handleRouterToTop() {
- const router = useRouter();
- router.beforeEach((to, from, next) => {
- // chrome
- document.body.scrollTop = 0;
- // firefox
- document.documentElement.scrollTop = 0;
- next();
- });
- return {};
- }
|