英文:
How can i create a route with underscore in next 13?
问题
我想创建一个以下划线开头的URL地址,但是我不能,因为next.js文档说它是一个私有文件夹!
我该怎么做呢?
示例:/shop/_t-shirt
英文:
I want to create a URL address that start with an underscore but i cant because next.js dacument said it was a private folder!
how can i do it?
example: /shop/_t-shirt
答案1
得分: 4
在第13版本中,Next.js提到了一种方法,您可以创建以下划线开头的URL段
https://nextjs.org/docs/app/building-your-application/routing/colocation
> 您可以通过在文件夹名称前缀中使用 %5F(下划线的URL编码形式)来创建以下划线开头的URL段: %5FfolderName。
所以您可以这样做:
/app
/shop
/%5Ft-shirt
page.tsx
英文:
In version 13, Next.js mentioned a way that you can create URL segments that start with an underscore
https://nextjs.org/docs/app/building-your-application/routing/colocation
>You can create URL segments that start with an underscore by prefixing the folder name with %5F (the URL-encoded form of an underscore): %5FfolderName.
so you can do it:
/app
/shop
/%5Ft-shirt
page.tsx
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论