//路由跳转后,页面回到顶部
router.afterEach(() => {
    document.body.scrollTop = 0;
    document.documentElement.scrollTop = 0;
}


二:js缓慢回到顶部

function top() {
  let currentPosition, timer;
  timer = setInterval(function () {
    currentPosition =
      document.documentElement.scrollTop || document.body.scrollTop;
    currentPosition -= 30;
    if (currentPosition > 0) {
      window.scrollTo(0, currentPosition);
    } else {
      window.scrollTo(0, 0);
      clearInterval(timer);
    }
  }, 1);
}