const top_page = () => { if (document.documentElement.scrollTop === 0) { return } let timmer; let h = document.documentElement.clientHeight let n = 0 timmer = setInterval(() => { n++; console.log('执行') if (n >= h / 20) { clearInterval(timmer) } document.documentElement.scrollTop -= 20 },16) }