我正在尝试遵循 Angular 2 文档来深入了解 Angular 2 的路由:https://angular.io/docs/ts/latest/guide/router.html#!#route-config
当我尝试按照说明重定向到默认页面时, typescript 编译器向我发送此错误:
Type '{ path: string; redirectTo: string; pathMatch: string; }' is not assignable to type 'Route'.
Object literal may only specify known properties, and 'pathMatch' does not exist in type 'Route'.
这是我的代码:
export const CrisisCenterRoutes: RouterConfig = [
{
path: '',
redirectTo: '/crisis-center',
pathMatch: 'full'
},
{
path: 'crisis-center',
component: CrisisCenterComponent,
children: [
{ path: ':id', component: CrisisDetailComponent },
{ path: '', component: CrisisListComponent }
]
},
{
path: 'admin',
component: CrisisAdminComponent
},
];
我找不到这个明显问题的任何解释。当我删除“pathMatch”属性时,代码将编译。
非常感谢您的解释。
最佳答案
您使用的版本有点旧。使用@angular/router
版本应为3.0.0-beta.2
关于javascript - Angular 2 路由器 + Angular-cli,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38271014/