【发布时间】:2021-05-12 15:57:48
【问题描述】:
【问题讨论】:
-
你考虑过使用optional catch all routes吗?它也应该捕获
/路径。
标签: next.js
【问题讨论】:
/ 路径。
标签: next.js
[...page].tsx 只会捕获 / 之后的路由,因此 http://localhost:3000/page1 或 http://localhost:3000/page1/page2 将进入 [...页].tsx
你可以从 nextjs 路由器中提取值
import {useRouter} from "next/router";
然后在你的组件中
const router = useRouter()
console.log(router.query.page)
【讨论】: