Router-link 跳转页面回到头部问题
在vue-router配置文件中添加如下代码
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
案例如下
export default () => {
return new Router({
mode: 'history',
base: process.env.BASE_URL,
routes,
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
})
}