🎈 perf: 新开标签时、返回标签时,滚动条回到顶部,否则会保留上次标签的滚动位置。
parent
9af4cad552
commit
ee7c73b475
|
|
@ -8,7 +8,15 @@ const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.VITE_BASE_PATH), // createWebHashHistory URL带#,createWebHistory URL不带#
|
history: createWebHistory(import.meta.env.VITE_BASE_PATH), // createWebHashHistory URL带#,createWebHistory URL不带#
|
||||||
strict: true,
|
strict: true,
|
||||||
routes: remainingRouter as RouteRecordRaw[],
|
routes: remainingRouter as RouteRecordRaw[],
|
||||||
scrollBehavior: () => ({ left: 0, top: 0 })
|
scrollBehavior: () => {
|
||||||
|
// 新开标签时、返回标签时,滚动条回到顶部,否则会保留上次标签的滚动位置。
|
||||||
|
const scrollbarWrap = document.querySelector('.v-layout-content-scrollbar .el-scrollbar__wrap')
|
||||||
|
if (scrollbarWrap) {
|
||||||
|
// scrollbarWrap.scrollTo({ left: 0, top: 0, behavior: 'auto' })
|
||||||
|
scrollbarWrap.scrollTop = 0
|
||||||
|
}
|
||||||
|
return { left: 0, top: 0 }
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
export const resetRouter = (): void => {
|
export const resetRouter = (): void => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue