javascript 404页面找不到Nextjs链接

zpgglvta  于 2023-05-05  发布在  Java
关注(0)|答案(2)|浏览(121)

我正在学习nextjs和我试图导航到ab组件在nextjs与链接组件可以任何人都可以请告诉我如何正确地做事情目前它给我404这个页面找不到。错误当我尝试这样做
页脚:

import React from 'react'
import Link from 'next/link'

export default function Footer() {
  return (
    <footer className="bg-black-800 py-12">
      <div className="container mx-auto px-4">
        <div className="flex flex-wrap justify-between">
          <nav className="w-full lg:w-auto lg:flex-1 lg:text-center flex flex-wrap justify-center">
            <Link href="/ab" className="footer-link mr-4">
              <span>Privacy Policy</span>
            </Link>
            <Link href="/terms" className="footer-link mr-4">
              <span>Terms of Service</span>
            </Link>
          </nav>
        </div>
      </div>
    </footer>
  )
}

组件:

import React from 'react'

export default function ab() {
  return (
    <div>
        <h1>Hello From compoent</h1>
    </div>
  )
}

wpx232ag

wpx232ag1#

您应该在pages目录中有一个ab.js文件,该文件中应该有如下代码

function Ab() {
    return <div>This is ab page</div>
}
  
export default Ab
rqdpfwrv

rqdpfwrv2#

// Missing curly brackets in href 

           <Link href={"/ab"} className="footer-link mr-4">
                 <span>Privacy Policy</span>
           </Link>

           <Link href={"/terms"} className="footer-link mr-4">
                 <span>Terms of Service</span>
           </Link>

相关问题