【发布时间】:2021-10-25 05:21:42
【问题描述】:
我一直在研究一些关于堆栈溢出的示例,用于在 react-router 中定义可选的查询参数,最后发现它可以像这样完成
{
path: '/forms/simulacao/:journeyId?',
exact: true,
name: 'Home',
component: Home,
authRequired: true
}
所以在下一步我想检索“journyeId”的查询参数,如果它在那里,所以我尝试了
const history=useHistory()
console.log(history.location)
但这似乎不起作用,应该有什么解决方法??
“反应路由器”:“^5.1.2”, "react-router-dom": "^5.1.2",
【问题讨论】:
标签: reactjs react-router react-router-dom react-router-v5