backTop() {
this.timer = setInterval(() => {
let topDistance =
document.documentElement.scrollTop || document.body.scrollTop;
let moveDistance = Math.floor(-topDistance / 5);
document.documentElement.scrollTop = document.body.scrollTop =
topDistance + moveDistance;
if (topDistance === 0) {
clearInterval(this.timer);
}
}, 30);
},
网友评论