简体   繁体   English

Nextjs 基于 id 的多条动态路由

[英]Nextjs Multiple dynamic Routes on the bases of ids

enter image description here在此处输入图像描述

Hi, I am working on the Nextjs project, and I have an issue, where I have Events->Event->Schedule.嗨,我正在处理 Nextjs 项目,但我遇到了一个问题,我有 Events->Event->Schedule。 I just want to click on the event it will be linked to the event, inside the event there will be a schedule that will be linked to the schedule component, there will be multiple events, and the routing should be dynamic.我只想点击将链接到事件的事件,事件内部会有一个日程表,将链接到日程表组件,会有多个事件,并且路由应该是动态的。 Folder structure is visible in Pic文件夹结构在图片中可见

Take a look at the Next.js documentation on Dynamic Routing:查看有关动态路由的 Next.js 文档:

https://nextjs.org/docs/routing/dynamic-routes https://nextjs.org/docs/routing/dynamic-routes

You would create a file structure similar to this:您将创建一个类似于此的文件结构:

pages/
-- events/
---- [eventId]/
------ schedule/
-------- [scheduleId].js

The last file would live at pages/events/[eventId]/schedule/[scheduleId].js .最后一个文件位于pages/events/[eventId]/schedule/[scheduleId].js In that page file, you would have access to both eventId and scheduleId as route parameters to look up the appropriate event and schedule.在该页面文件中,您可以访问eventIdscheduleId作为路由参数来查找适当的事件和时间表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM