// 平滑滚动到顶部 // scrollDom 出现滚动条,要滚动的元素 // speed 平滑滚动的速度 number类型 const scrollToTopSmooth = (scrollDom, speed) => { let scrollTop = scrollDom.scrollTop function move() { scrollTop -= speed scrollDom.scrollTop = scrollTop if (scrollTop > 0) { window.requestAnimationFrame(move) } else { scrollDom.scrollTop = 0 } } move() } export default scrollToTopSmooth
标签:滚动,平滑,move,js,scrollDom,scrollTop,speed From: https://www.cnblogs.com/shidawang/p/17387221.html