跳至內容
文件錯誤沒有 Head 元素

沒有 Head 元素

避免使用 <head> 元素。

錯誤發生原因

使用了 <head> 元素來包含頁面層級的詮釋資料,但這可能會在 Next.js 應用程式中造成非預期的行為。請改用 Next.js 內建的 next/head 組件。

可能的解決方法

導入並使用 <Head /> 組件

pages/index.js
import Head from 'next/head'
 
function Index() {
  return (
    <>
      <Head>
        <title>My page title</title>
        <meta name="viewport" content="initial-scale=1.0, width=device-width" />
      </Head>
    </>
  )
}
 
export default Index