mirror of
https://github.com/PlayEdu/backend
synced 2025-12-28 01:19:45 +08:00
自动滚到到顶部
This commit is contained in:
12
src/AutoTop.ts
Normal file
12
src/AutoTop.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useLayoutEffect } from "react";
|
||||
import { useLocation } from "react-router-dom";
|
||||
|
||||
const AutoScorllTop = ({ children }) => {
|
||||
const location = useLocation();
|
||||
useLayoutEffect(() => {
|
||||
document.documentElement.scrollTo(0, 0);
|
||||
}, [location.pathname]);
|
||||
return children;
|
||||
};
|
||||
|
||||
export default AutoScorllTop;
|
||||
Reference in New Issue
Block a user