vue 解决跳转新页面时无法回到顶部的问题
Sonder
2020-10-07
394字
1分钟
浏览 (3k)
最近写一个项目当页面跳到新的页面时滚动条总是在当前位置

然后在router.js
里面加了
const createRouter = () => new Router({
mode: 'history',
scrollBehavior: () => ({y: 0,x: 0}),
routes: constantRoutes
});
scrollBehavior: () => ({y: 0,x: 0}),
还是没有用
结果打开审查元素发现是因为给body
加了overflow: auto;
html, body {
min-height: 100%;
padding: 0;
margin: 0;
//overflow: auto;
min-width: 1210px;
}
完美解决!