let time = setInterval(() => {
let scroll = document.documentElement.scrollTop || document.body.scrollTop;//解决scrollTop始终为零,尽此行代码
if (scroll <= 100) {
clearInterval(time);
} else {
if (scroll >= 200) {
document.documentElement.scrollTop = scroll -= Math.ceil(
scroll / 30
);
document.body.scrollTop = scroll -= Math.ceil(
scroll / 30
);
} else {
clearInterval(time);
}
}
}, 10);