对于xxx / xxx之类的嵌套路由,如何正确使用通配符路由?
我想将host:port / XXX / XXX重定向到页面未找到,但是,我的通配路由仅接受路由host:port / XXX,而不接受host:port / XXX / XXX。
这是我在app.module.ts上配置的路由:
const routes: Routes = [
{
path: 'main',
component: MainComponent
},
{
path: '',
component: PageNotFoundComponent
},
{
path: '**',
redirectTo: ''
}
];
RouterModule.forRoot(routes)
我的文件:(使用Angular 10.0.10)
app
--- page-not-found/page-not-found.component.ts
--- main/maincomponent.ts
--- app.component.ts
--- app.module.ts
assets
environment
index.html
main.ts
style.css
… (other files auto generated by angular cli)
谢谢。