# 滚动到顶部
当前页面平滑滚动到顶部
import { scrollToTop } from 'util-snippets'
scrollToTop()
const scrollToTop = () => {
const c: number = document.documentElement.scrollTop || document.body.scrollTop;
if (c > 0) {
window.requestAnimationFrame(scrollToTop);
window.scrollTo(0, c - c / 8);
}
};
← 检查当前标签页是否活动 跳转页面 →