toTop(){
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);
}
}, 10);
}
js页面回到顶部
最新推荐文章于 2024-03-19 10:15:00 发布