javascript - 使用 React Router 4 保护一组路由
问题描述
在 React Router 4 中玩弄受保护的路由,并想知道我已经能够开始工作的东西是否可能。
<Switch>
<Route exact path="/" component={LandingPage} />
<Route path="/sign-in" component={SignIn} />
<Route exact path="/auth/home" component={Home} />
<Route exact path="/auth/my-profile" component={UserProfile} />
<ProtectedRoute path="/auth" />
</Switch>
我有这些路线,如上所示,我已经设置了一个名为的受保护路线/auth
我想要的是用它来保护任何和所有从/auth
所以在这个例子中
<Route exact path="/auth/home" component={Home} />
<Route exact path="/auth/my-profile" component={UserProfile} />
也将是受保护的路线。
说得通?
解决方案
推荐阅读
- php - 如果包含时间,如何过滤日期
- jenkins - 空手道测试执行
- javascript - 在 aws 上使用 Godaddy SMTP 服务器的 Nodemailer 连接超时错误
- python - 使用 pipenv 安装 pyrebase 失败
- reactjs - 更新状态而不重新渲染 ArcGIS 地图
- javascript - 提取给定日期范围的 JSON 总和?
- python-3.x - Trello API / Python - 无法为卡片设置自定义字段值
- java - 在 Java 中读取巨大的 Json 响应时内存不足
- java - 如何在实时服务器上部署 Spring Boot 应用程序并与 mysql 建立数据库连接
- powershell - gvim 8.2 不会粘贴在 powershell 中的 Windows 10 上