diff --git a/app/layout.js b/app/layout.js index a3be66c..907ab8a 100644 --- a/app/layout.js +++ b/app/layout.js @@ -1,6 +1,7 @@ "use client"; import { Inter } from "next/font/google"; -import React from "react"; +import React, { useEffect } from "react"; +import { usePathname } from "next/navigation"; import "./globals.css"; import BottomNav from "../components/BottomNav"; import { Provider } from "react-redux"; @@ -31,6 +32,17 @@ const metadata = { // userScalable: 0, // }; export default function RootLayout({ children }) { + const pathname = usePathname(); + useEffect(()=>{ + const timer = setTimeout(() => { + window.scrollTo({ + top: 0, + left: 0, + behavior: "smooth", // 可选,平滑滚动效果 + }); + clearTimeout(timer); + }, 100); + },[pathname]) return ( {/* */} {/* */} - + {/* */} {/* */} {/* */} @@ -199,7 +211,7 @@ export default function RootLayout({ children }) { )} {/* {children} */} -