在路由的js中加入
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return {
x: 0, y: 0 }
}
},
列如:
export default new Router({
// mode: 'history',
mode: 'history',
scrollBehavior (to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {
return {
x: 0, y: 0 }
}
},
转载:https://blog.csdn.net/ZiChen_Jiang/article/details/108263499
查看评论