【发布时间】:2021-08-16 14:10:43
【问题描述】:
我在 pages 文件夹中创建了一个名为 dashboard 的文件夹,其中包含以下文件:
- index.tsx
- customers.tsx
- invoice.tsx
- items.tsx
当用户路由到http://localhost:3000/dashboard 时,会呈现index.tsx 页面。但是,当我单击按钮并路由到发票或客户时,当我检查路由到 http://localhost:3000/customers 和 http://localhost:3000/invoices 而不是 http://localhost:3000/dashboard/customers 和 http://localhost:3000/dashboard/invoices 的 URL 时,我得到一个 404 page
但是当我尝试在 href 中为客户编写完整路线时:
//It will work after refreshing the page
<Link href='dashboard/customers'>
<a>Customers</a>
</Link>
当我尝试将客户的任何路线路由到任何嵌套页面时,例如:
<Link href='dashboard/invoices'>
<a>Customers</a>
</Link>
// I tend to get a 404 page
当我检查网址时,它执行了以下操作:http://localhost:3000/dashboard/dashboard/invoices 而不是 http://localhost:3000/dashboard/invoices
下面的按钮代码:
<Link href='/customers'>
<a>Customers</a>
</Link>
<Link href='/invoices'>
<a>Invoices</a>
</Link>
真的不知道自己做错了什么
【问题讨论】:
标签: typescript next.js