我正在将一个React应用程序迁移到Next.js。
由于Next.js不使用"react-router-dom",所以我需要更改一些ReactiveR外层钩子,以便它们能够与Next.js一起工作。
其中一个是useRouteMatch。
我想让这行代码与Next.js一起工作-
const match = useRouteMatch<{lang?: Language}>('/map/:lang([a-z]{2})?');我还没有找到一种类似的方法或解决办法。
有人有什么建议吗?
发布于 2022-10-13 07:00:22
关于nextjs路由的所有内容都在next/路由中。
你可能在看router.pathname
const Component = () => {
const router = useRouter() //now u can use the router object
}https://nextjs.org/docs/api-reference/next/router#router-object
https://stackoverflow.com/questions/74051603
复制相似问题