vue项目路由跳转设置自动滚动到页面顶部

 
new Router({ scrollBehavior: () => ({ y: 0 }), routes })
 
 
如果是元素的话使用scrollTo方法
示例:el.scrollTo(x, y)   x为横向位置,y为纵向位置
posted @ 2022-09-09 14:15  丿流水  阅读(185)  评论(0)    收藏  举报