Ibr*_*bra 2 next.js dynamic-routing
我想在 nextjs 中创建动态页面以匹配以下路线users/[user]/[dashboard]
。我的文件结构
pages/
users/
-[user].js // will match for /users/123
- index.js // will match for /users
dashboard/
- [dashboard].js // will match for /users/1234/ABCD
Run Code Online (Sandbox Code Playgroud)
我只收到[user]
查询参数中的 ,而不是 [dashboard].js 内的 [dashboard] 。有人可以解释如何安排文件结构以匹配users/[user]/[dashboard]
要匹配以下动态路由,您可以按如下方式users/[user]/[dashboard]
构建文件夹:pages
pages/
users/
index.js // Matches `/users` route
[user]/
index.js // Matches `/users/user123` routes
[dashboard]/
index.js // Matches `/users/user123/dashboardABC` routes
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2742 次 |
最近记录: |