angular - 页面重新加载后Angular 9不需要的重定向
问题描述
我很难理解 Angular 路由器的行为。目前,路由模块如下所示:
const routes: Routes = [
{
path: '',
component: ManageCompetitionComponent,
children: [
{
path: ':eventID',
component: EventProfileComponent,
},
],
}];
当我打开http://localhost:4200/admin/competition
并单击导航到它的链接时,http://localhost:4200/admin/competition/1234
它工作正常,并且EventProfileComponent
显示为ManageCompetitionComponent
(包含路由器插座)的一部分。
但是当我现在从浏览器调用时(例如刷新/F5):
http://localhost:4200/admin/competition -> works fine
http://localhost:4200/admin/competition/1234 -> redirects to /admin/competition
那么我怎样才能防止这种重定向呢?
解决方案
尝试这个,
const routes: Routes = [
{
path: '',
component: ManageCompetitionComponent,
},
{
path: ':eventID',
component: EventProfileComponent,
}];
推荐阅读
- php - 检查输入框中的字符串是否等于 SQL SERVER、PHP 中的 varbinary(max) | SQL 服务器 2012
- makefile - (Makefile 错误:*** 缺少分隔符)以下 makefile 在我的本地 IDE 中工作正常,但在 Putty 客户端中运行时失败
- javascript - 在本机反应中隐藏条件视图
- wordpress - .htaccess 随机破坏重定向
- javascript - 使用 Object.assign 和 lodashs _.merge 函数返回新的未变异状态?
- oracle - 在期待其中之一时遇到符号“INNER”
- wordpress - Wordpress - dynamic_sidebar - 导致加载 XML 时出错
- jquery - 基于 jQuery 的文本搜索/过滤器有效,但不适用于所有字段
- java - 文件提供程序 Uri 错误
- mongodb - 根据 Mongodb 中字段的平均值计算文档