小编Jes*_*key的帖子

NextJS 13 root.layout 在底部渲染 NavBar。有没有办法一致地将导航栏渲染在顶部?

我正在尝试构建 Next13 应用程序。新的布局很酷,但它扰乱了渲染。我不完全理解布局中渲染对象的顺序:

导航栏.tsx

"use client";
import Link from "next/link";

export default () => {
  return (
    <span className="flex justify-between">
      <h1 className="text-xl">Navigation Bar</h1>
      <ul className="flex gap-4">
        <li>
          <Link href="/">Home</Link>
        </li>
        <li>
          <Link href="/user/login">Login</Link>
        </li>
        <li>
          <Link href="/user/signup">Sign Up</Link>
        </li>
      </ul>
    </span>
  );
};

Run Code Online (Sandbox Code Playgroud)

布局.tsx

import "./globals.css";
import NavBar from "./NavBar";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html className="bg-slate-500 font-robslab" lang="en">
      <head>
        <title>Stylitique</title>
        <meta name="description" content="Generated by create next app" />
        <link rel="icon" href="/favicon.ico" …
Run Code Online (Sandbox Code Playgroud)

layout routes reactjs server-side-rendering next.js

2
推荐指数
1
解决办法
3850
查看次数

标签 统计

layout ×1

next.js ×1

reactjs ×1

routes ×1

server-side-rendering ×1