我的路線:找不到頁面處理,而不改變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} –
如果你有東西,請重播。 –
它沒有幫助我 –