创建一个组件来包装每个页面并希望接收每个页面的子级和标题会引发错误。 “标题元素收到一个包含超过 1 个元素作为子元素的数组。”
import Head from "next/head";
interface IProps {
children: JSX.Element;
title?: string;
restProps?: any;
}
export default function MetaDataContainer(props: IProps) {
const {
children,
title = "Generated by create next app",
...restProps
} = props;
return (
<>
<Head>
<title>CV-stack - {title}</title>
<meta name="description" content="Generated by create next app" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>{children}</main>
</>
);
}
你需要提供一个像这样的对象
<title>{`CV-stack - ${title}`}</title>
因为这个评论中解释的原因(react dom string rendering)https://github.com/vercel/next.js/discussions/38256 https://github.com/vercel/next.js/discussions/38256
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)