English 中文(简体)
其次,js 404 乘机参观动态路线,结构正确
原标题:Next.js 404 Error when visiting dynamic route with correct folder structure

I m在试图访问我的下一个项目的动态路线时遇到404个错误(本页无法找到)。 具体路线是:http:// localhost:3000/blog/id, 和Im, 在其最新版本中使用Henjs。

Here s my folder structure:

 app
  blog
    [id].tsx
       page.tsx

我期待[id]。 处理动态路线的帐篷档案,但出于某种原因,它没有按预期运作。

有什么想法可能给这一问题造成什么问题,或我如何使这个问题进一步恶化?

事先感谢你们的帮助!

我期待[id]。 处理动态路线的帐篷档案,但出于某种原因,它没有按预期运作。

问题回答

看来,文件夹或文件名称,或您的主编的结构是不正确的。 <代码>[id]应为文件夹,而不是文件。 如果它已经翻了一番,则删除其名称,例如<代码>.tsx。

现行结构:

blog > [id].tsx > page.tsx

Corrected structure:

blog > [id] > page.tsx

The pages directory in Next.js supports dynamic routes through file naming conventions. However, the app directory does not function in the same way. That s why we must use directories (folders) instead of file names in the Next app directory.





相关问题
select multiple files in file upload in php? [duplicate]

Possible Duplicate: How to select multiple files for upload? i know that php doesn t allow you to select multiple files to upload in one box. is there a work around or do you have to learn ...

Connecting Actionscript 3.0 with a C++ backend?

I am curious to know if there is a way of connecting a flash front-end to a C++ driven backend? I m not currently working on a project that involves this, but I found out about an application used in ...

PHP searchable catalog design

I m working on a PHP Real Estate catalog. I am working on the search part right now and I m having trouble with the logic. Should the default view show all items in the catalog or the search page? ...

jquery image preview that work on ajax embedded image links?

there are various good jquery image preview plugins out there. however, all of the ones i ve tested havent worked on image links that are embedded in the DOM with ajax. i have tested use jquery live ...

Why should I use XFN in my HTML?

What is the benefit of using XFN (XHTML Friends Network)? I ve seen this on multiple blogs and social networking sites but I don t really understand why it s useful. Other than being able to style ...

The modern way to clear floated content?

What s the modern way to clear floated content these days? There s the "recent" modern way of adding a ".clearfix" on the parent element to clear the contained floats and that would work great. In ...

create a "show up" window when you click register?

im a backend programmer who wants to have a window that appears in front of the current window when clicking "register". so that you dont have to redirect to another page. i think u guys know what i ...

热门标签