Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
mlaj-reading-club
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-04-21 15:37:06 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a23e1f3210d2f2e7df6d313c9a3ee15a769d17b8
a23e1f32
1 parent
deb81762
feat(router): 添加路由切换后页面滚动到顶部的功能
在路由配置中添加了 `scrollBehavior` 方法,确保每次路由切换后页面滚动到顶部,提升用户体验。
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
src/main.js
src/main.js
View file @
a23e1f3
/*
* @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
)
...
...
Please
register
or
login
to post a comment