无法导航到具有在Angular2中按名称指定的redirectTo的路由
发布时间:2020-12-17 17:15:51 所属栏目:安全 来源:网络整理
导读:我的RouteConfig定义了以下路径 @RouteConfig ([ { path:'/main',name:'Home',redirectTo: ['Setup']},{ path:'/setup',name:'Setup',component:SetupComponent},{ path:'/configuration',name:'Configuration',component:ConfigurationComponent},]) 在我的
我的RouteConfig定义了以下路径
@RouteConfig ([ { path:'/main',name:'Home',redirectTo: ['Setup']},{ path:'/setup',name:'Setup',component:SetupComponent},{ path:'/configuration',name:'Configuration',component:ConfigurationComponent},]) 在我的模板中 <ol> <li><a [routerLink]="['Setup']">Setup</a></li> <li><a [routerLink]="['Configuration']">Configuration</a></li> <li><a [routerLink]="['Home']">Home</a></li> </ol> 在组件中,我尝试过一种方法 this._Router.navigate(['Home']); 在这两种情况下,(使用routerLink指令和Router.navigate方法)在尝试导航到“Home”路由时,我收到以下错误. Component "AppComponent" has no route named "Home" 而具有与其关联的组件的路线都按预期工作.从Children路由器调用它们时的行为也是如此. 如何路由/导航到名为“Home”的路由? 解决方法
您无法为重定向路由指定名称.由于Home重定向到名为Setup的路由,我将使用Setup名称.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |