gpt4 book ai didi

javascript - 警告 : Expected server HTML to contain a matching in

转载 作者:行者123 更新时间:2023-12-05 02:08:30 26 4
gpt4 key购买 nike

我在控制台中收到上述警告。我不明白为什么。我有两个匹配 <body> index.js 中的标签文件。完整的警告是 -

Warning: Expected server HTML to contain a matching <body> in <div>.
in body (at pages/index.js:12)
in div (at pages/index.js:11)
in div (at pages/index.js:7)
in Index (at _app.js:8)
in MyApp
in Container (created by AppContainer)
in AppContainer

在我使用的 index.js 文件之后。我将 Next.js 与 tailwindcss 结合使用。

import Head from "next/head"
import SideNavbar from "../components/SideNavbar"
import MainPage from "../components/MainPage"

const Index = () => {
return (
<div className="mx-auto">
<Head>
<title>Manchester United</title>
</Head>
<body className="min-h-screen">
<div className="flex flex-row">
<SideNavbar />
<MainPage>
<div className="text-center px-2 py-6 text-5xl font-bold text-gray-200">
Manchester United
</div>
</MainPage>
</div>
</body>
</div>
)
}

export default Index

如果我更换 <body>,警告就会消失带有 <div> 的标签标签。我使用的两个自定义组件,<SideNavbar /><MainPage /> , 不要使用任何 <body>标签。

最佳答案

您的 HTML 不正确。您不能在 div 标签中包含 body 标签。基本的 HTML 结构如下所示

<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>
<div></div>

</body>
</html>

关于javascript - 警告 : Expected server HTML to contain a matching <body> in <div>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60830506/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com