我正在使用 NextJs 14(App Router 版本)。我想为主应用程序创建一个登录和注册页面布局以及一个单独的布局。我的根布局看起来像这样
export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={rubik.className} >
<Providers>
{children}
</Providers>
</body>
</html>
);
}
我在
app/overview
中有另一个布局。现在,如果我为登录和注册页面制作此 RootLayout 布局,它将出现在应用程序布局中。我怎样才能将它分开?我怎样才能有两个不重叠的布局
app/layout.tsx
为应用程序共享,如下所示:export default function RootLayout({children}) {
return (
<html>
<body>{children}</body>
</html>
)
}
(this-structure)
的文件夹,然后将 login
和 register
添加到其中。这称为路线组。app/
- layout.tsx <-- root layout
- (auth)/
- layout.tsx <-- auth layout
- login/page.tsx
- register/page.tsx
- ...
- overview
- layout.tsx <-- app layout
- page.tsx
- about/
- page.tsx
- ...
了解更多关于航线组的信息: https://nextjs.org/docs/app/building-your-application/routing/route-groups