backTop() { var top = document.body.scrollTop || document.documentElement.scrollTop; this.duration -= 3; this.duration = this.duration <= 0 ? 1 : this.duration; var speed = top / this.duration; document.documentElement.scrollTop -= speed; if (top > 0) { this.timer = setTimeout(() => { this.backTop(); }, 16); } else { this.duration = 50; clearTimeout(this.timer); } }