hookehuyr

feat(router): 添加路由切换后页面滚动到顶部的功能

在路由配置中添加了 `scrollBehavior` 方法,确保每次路由切换后页面滚动到顶部,提升用户体验。
/*
* @Date: 2025-04-17 14:26:17
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-04-21 15:07:36
* @LastEditTime: 2025-04-21 15:36:27
* @FilePath: /mlaj-reading-club/src/main.js
* @Description: 文件描述
*/
......@@ -30,7 +30,11 @@ const router = createRouter({
{ path: '/check-in/:id', component: () => import('./pages/CheckIn.vue') },
{ path: '/messages', component: () => import('./pages/Messages.vue') },
{ path: '/:pathMatch(.*)*', redirect: '/' }
]
],
scrollBehavior(to, from, savedPosition) {
// 每次路由切换后,页面滚动到顶部
return savedPosition || { top: 0, left: 0 }
},
})
app.use(router)
......