我可以在nextJ中获得动态路由,以换取未知数量的slug数的嵌套路由吗?
在NextJS中,路由是基于页面的路径,但无论如何都可以实现以下途径:
http://localhost/abc/element/id
http://localhost/abc/def/element/id
http://localhost/abc/def/ghi/element/id
请注意/元素/ID在所有
中是如何常见的
如何使用嵌套文件夹结构并将其重定向到同一组件的所有内容,但是我想避免使用相同的内容,因为我们可以进一步嵌套。
请注意,您不能使用所有捕获量,因为它应该在文件扩展之前结束。 另外,我不想在URL中添加额外的前缀,因为这会使较旧的URL无效。
In nextJS routing is path based for pages but is there anyway to achieve a common route for following:
http://localhost/abc/element/id
http://localhost/abc/def/element/id
http://localhost/abc/def/ghi/element/id
Note how /element/id is common in all
I understand i can make nested folder structure and redirect them to same component but i want to avoid the same as we can further more nesting.
Do take care that you can not use catch all as it should be at the end just before file extension.
Also, i don't want to add an extra prefix to the URL as that makes the older url's invalid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论