请解释下面的2个代码片段之间的区别:
const routes: Routes = [
{
path: '',
canActivate: [AuthGuard],
component: MainComponent,
children: [
{
path: '',
component: DashboardComponent
},
{
path: 'items/add',
component: AddItemComponent
},
{
path: 'items/:type/sandbox',
component: SandboxComponent
},
{
path: 'items/:id',
component: EditWrapperComponent
},
{
path: 'items/:account/:id',
component: EditWrapperComponent
}
]
}
];
当我调用localhost:4200/items/app/sandbox
(app是类型)但代码片段2不起作用时,代码片段1也可以正常工作。
我不知道为什么这样请帮忙解释一下:)
在代码片段2中,由于排序,/items/app/sandbox
被路由到'items/:account/:id
。