我使用Angular路由器,可以使用路径:' **'对于404页
export const AppRoutes: Routes = [
{path: '', redirectTo: 'dashboard', pathMatch: 'full'},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{
path: '',
component: FullComponent,
canLoad: [LoginGuard],
children: [
{
path: '',
loadChildren: () => import('./material-component/material.module').then(m => m.MaterialComponentsModule)
},
{path: 'dashboard', loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule)}
]
},
{path: '**', component: PageNotFoundComponent}
];
但是404页面只能匹配:'/a''/b'无法匹配:'/a/b''/c/d'
我认为'''''''''''''''''''''''''''' >
export const AppRoutes: Routes = [
{path: '', redirectTo: 'dashboard', pathMatch: 'full'},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{
path: '',
component: FullComponent,
canLoad: [LoginGuard],
children: [
{
path: '',
loadChildren: () => import('./material-component/material.module').then(m => m.MaterialComponentsModule)
},
{path: 'dashboard', loadChildren: () => import('./dashboard/dashboard.module').then(m => m.DashboardModule)}
]
},
{path: '**', component: PageNotFoundComponent}
];
but 404 page can only match: '/a' '/b' can't match: '/a/b' '/c/d'
I think the '' url is not correct with childen:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的问题是,您的代码应该看起来像这样。
以及在MaterialComponentRountingModule中
You're right the problem is that.Your code should look like this .
And in the MaterialComponentRountingModule
你能尝试吗
Can you try with