回到顶部实现滚动效果

goTop() {
            let top = document.documentElement.scrollTop || document.body.scrollTop
            // 实现滚动效果
            const timeTop = setInterval(() => {
              document.body.scrollTop = document.documentElement.scrollTop = top -= 50
              if (top <= 0) {
                clearInterval(timeTop)
              }
            }, 10)
          },

 

posted @ 2022-06-07 17:36  李云蹊  阅读(18)  评论(0编辑  收藏  举报