Commit 95cb5d1c authored by lipengcheng 's avatar lipengcheng

feat: 滚动行为优化

parent b9396539
......@@ -30,14 +30,26 @@ const router = new VueRouter({
base: process.env.BASE_URL,
routes,
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
if (from.meta.keepAlive) {
from.meta.savedPosition = document.body.scrollTop
}
return { x: 0, y: to.meta.savedPosition || 0 }
}
// if (savedPosition) {
// return savedPosition
// } else {
// if (from.meta.keepAlive) {
// from.meta.savedPosition = document.body.scrollTop
// }
// return { x: 0, y: to.meta.savedPosition || 0 }
// }
return new Promise((resolve) => {
setTimeout(() => {
if (savedPosition) {
resolve(savedPosition)
} else {
if (from.meta.keepAlive) {
from.meta.savedPosition = document.body.scrollTop
}
resolve({ x: 0, y: to.meta.savedPosition || 0 })
}
}, 500)
})
}
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment