解决vue路由跳转到新页面时,默认展示最下面内容的问题

问题描述

vue路由跳转到新页面时,默认展示到最下面:


解决方案:

在页面加载完毕时,把滚动条的距离设置为(0 , 0)就可以了

mounted(){
    
    
    this.$router.afterEach((to,form,next)=>{
    
    
        window.scrollTo(0,0)
    })
}

猜你喜欢

转载自blog.csdn.net/qq_50906507/article/details/127474797