问题:页面跳转回不到顶部
const router = new VueRouter({
scrollBehavior (to, from, savedPosition) {
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 }
}
}
})
解决方案:
router.beforeEach((to, from, next) => {
document.documentElement.scrollTop = 0;
})