reactjs - 反应路由:使用 id_token 开关无法按预期工作
问题描述
我在 React 中使用以下路由语句:
<Switch>
<Redirect from="/start" to="/xyz" />
<Route path="/xyz" component={MyTab} />
<Route exact path="**" component={NotFound} />
</Switch>
现在,在我的浏览器中,我使用哈希片段转到/start路径。我观察到的是:
- 当哈希片段只有状态
(例如
http://localhost:3000/start#state=ABC
)时,我最终进入了 MyTab,正如预期的那样。 - 当哈希片段同时具有state和
id_token(例如
http://localhost:3000/start#state=ABC&id_token=PQR
)时,我最终会进入 NotFound,这与预期的不同。
为什么以及如何使第二个案例最终出现在 MyTab 中?
解决方案
以下内容应该适合您:
<Switch>
<Route path="/start" component={MyTab} />
<Route path="/xyz" component={MyTab} />
<Route component={NotFound} />
</Switch>
推荐阅读
- tensorflow - 我们如何裁剪派生变量,以便相应地裁剪可训练值的值
- python - 如何使用 python 在 aws s3 预签名的 url 中隐藏我的访问密钥
- html - 滑块在页面中未正确呈现
- python - 如何将调查的答案存储在 python 数据框中
- ios - 为什么使用情节提要在 UIScrollView 中不显示内容
- node.js - RabbitMQ 重新连接逻辑不适用于 RabbitMQ 服务器的突然重启
- android - 使用 Coroutines kotlin 创建顺序请求
- authentication - Nginx:密码保护文件夹除了索引页
- optimization - Isight 程序没有读取 .inp 文件,而是读取了 .cae 文件
- reactjs - 如何使用酶 suspenseFallback 来期待 Suspense 和 Lazy?