跳转页面,滚动条保持上一个页面的位置
2020-12-16 本文已影响0人
Computer_计算机
先直接上代码-在router--index.ts里面加入下面的代码-每次跳转路由就会将滚动条置顶
scrollBehavior(to, from, savedPosition) {
if(savedPosition) {
return savedPosition
} else {
return {
x: 0,
y: 0
}
}
}
