gpt4 book ai didi

javascript - 警告 : next-head-count is missing

转载 作者:行者123 更新时间:2023-12-03 23:46:34 24 4
gpt4 key购买 nike

我正在使用来自 Next documentation. 的自定义 _document.js结果,我不断收到打印到控制台的警告消息。我尝试重新启动服务器并清空浏览器的缓存。我的 _document.js 应该在“pages”文件夹中。我通过在我的 <Head> 中添加一些标签来确保正在读取该文件。并检查我的网站以查看标签是否被添加到 <Head> . (我的网站工作正常我只是厌倦了这个警告信息。)

控制台警告:

Warning: next-head-count is missing. https://err.sh/next.js/next-head-count-missing

这是我的 _document.js 文件:
import Document, { Html, Head, Main, NextScript } from 'next/document'

class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
}

render() {
return (
<Html>
<Head>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}

export default MyDocument

最佳答案

当将不受支持的 html 标签添加到 <Head> 中时,也会出现此错误。标签。
就我而言,我不小心添加了 <p>...</p> <Head>...</Head> 中的标签组件中的标记,引发此错误。

关于javascript - 警告 : next-head-count is missing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62385332/

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