我有一个 Cookiebot 脚本,我将其包含在我的根布局组件的顶部。
现在,当我最初加载页面时,Cookiebot 横幅会显示并正常工作。但是,如果我没有拒绝或接受,所以不单击任何内容,然后重新加载页面,我会在控制台中收到水合错误,并且 Cookiebot 脚本不再显示。 如果我删除 Cookiebot 脚本,错误就不会再发生。
'use client'
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="COOKIEBOT_ID" type="text/javascript" async></script>
…the rest of the code
</head>
</html>
)
}
这些是错误:
<noscript>
中包含匹配的 <div>
。<#document>
中的客户端内容。编辑:
不应使用同步脚本。请参阅:https://nextjs.org/docs/messages/no-sync-scripts