路由跳转,页面位置不在顶部

在对应路由的页面,添加一个scrollBehavior方法

const router = new VueRouter({ 
  routes,
  scrollBehavior(to, from, saveTop) { 
    if (saveTop) { 
      return saveTop; 
    } else { 
      return { x: 0, y: 0 } 
      } 
    },
  })
原文地址:https://www.cnblogs.com/zsj-02-14/p/15242395.html