zl程序教程

您现在的位置是:首页 >  后端

当前栏目

[Next.js] Override the Default Next.js Document

JS The Default Document Next override
2023-09-14 09:00:45 时间

The Document is like the top level HTML structure of your Next.js application. You can use document to change the default language, set favicon;

Because Document only render on Server side, so it doesn't support event such as onClick....

pages/_document.txs

import { Html, Head, Main, NextScript } from "next/document";

export default function Document() {
  return (
    <Html lang="en">
      <Head>
          <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22" />
      </Head>
      <body>
        <Main />
        <NextScript />
      </body>
    </Html>
  )
}