vue项目功能组件大全

155 阅读1分钟
       // 返回顶部功能组件
backtop() { 
  const timer = setInterval(function() {
    const top = document.documentElement.scrollTop || document.body.scrollTop;
    const speed = Math.floor(-top / 5);
    document.documentElement.scrollTop = document.body.scrollTop =
      top + speed;

    if (top === 0) {
      clearInterval(timer);
    }
  }, 20);
},