我的路线:找不到页面处理,而不改变URL角2
const routes: Routes = [
{ path: '', component: DashboardComponent, canActivate: [RouteGuard, AuthGuard] },
{ path: 'signup', component: SignUpTenantComponent, canActivate: [RouteGuard] },
{ path: 'signin', component: SignInComponent, canActivate: [RouteGuard] },
{ path: ':url', component: DashboardComponent, canActivate: [RouteGuard, AuthGuard] },
{ path: 'page-not-found', component: PageNotFoundComponent },
{ path: '**', redirectTo: 'page-not-found' }
];
而且我有守卫在那里我检查的网址,如果它是错误的,那么在PageNotfoundComponent
重定向:
this.router.navigate(['page-not-found']);
而作为一个结果我在url localhost:port/page-not-found
中看到。但是我想在不改变url的情况下做到这一点。 如果我将{ skipLocationChange: true }
添加到router.navigate
那么我会看到主要的网址localhost:port/
。 我想查看错误的网址,例如localhost:port/rgqadff
与PageNotFoundComponent
的内容。
我该如何解决?
不知道,但尝试路线的最后一个对象改变为:{路径:' **',组件:PageNotFoundComponent} –
如果你有东西,请重播。 –
它没有帮助我 –