Showing
1 changed file
with
5 additions
and
1 deletions
| 1 | /* | 1 | /* |
| 2 | * @Date: 2025-03-20 20:36:36 | 2 | * @Date: 2025-03-20 20:36:36 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2025-03-20 21:47:32 | 4 | + * @LastEditTime: 2025-03-20 22:46:37 |
| 5 | * @FilePath: /mlaj/src/router/index.js | 5 | * @FilePath: /mlaj/src/router/index.js |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | */ | 7 | */ |
| ... | @@ -69,6 +69,10 @@ const routes = [ | ... | @@ -69,6 +69,10 @@ const routes = [ |
| 69 | const router = createRouter({ | 69 | const router = createRouter({ |
| 70 | history: createWebHistory(), | 70 | history: createWebHistory(), |
| 71 | routes, | 71 | routes, |
| 72 | + scrollBehavior(to, from, savedPosition) { | ||
| 73 | + // 每次路由切换后,页面滚动到顶部 | ||
| 74 | + return savedPosition || { top: 0, left: 0 } | ||
| 75 | + } | ||
| 72 | }) | 76 | }) |
| 73 | 77 | ||
| 74 | export default router | 78 | export default router | ... | ... |
-
Please register or login to post a comment