我正在尝试使用RC5中的路由器3.0.0.rc-3将我们的应用程序升级到角度2 RC7。 但是我在子路由文件上遇到以下错误。
ERROR in [default] C:/src/app/routes/childroute1/child-routes-one.routes.ts:31:8
Type '{ path: string; component: typeof childRouteOne; data: { displayName: string; }; childre...' is not assignable to type 'Route[]'.
Type '{ path: string; component: typeof childRouteOne; data: { displayName: string; }; childre...' is not assignable to type 'Route'.
Types of property 'children' are incompatible.
Type '({ path: string; redirectTo: string; terminal: boolean; } | { path: string; component: typeof fea...' is not assignable to type 'Route[]'.
Type '{ path: string; redirectTo: string; terminal: boolean; } | { path: string; component: typeof feas...' is not assignable to type 'Route'.
Type '{ path: string; redirectTo: string; terminal: boolean; }' is not assignable to type 'Route'.
Object literal may only specify known properties, and 'terminal' does not exist in type 'Route'.
我是否必须更改(添加或删除)子路由中的任何内容?或者是任何依赖项的问题?
当我尝试使用@angular/router : 3.0.0.rc-2
和rxjs: 5.0.0-beta.6
时,我没有收到错误消息。
子的路由-one.routes.ts
import {Routes, ActivatedRoute} from '@angular/router';
export const settingsRoute: Routes = [
{
path: 'ev/route-one/:Id/:usrId',
component: childRouteOne,
data: { displayName: 'Settings' },
children: [
{
path: '',
redirectTo: 'home',
terminal: true
},
{ path: 'home', component: feature-home, data: { displayName: 'Home' } },
{ path: 'notes/notes-settings/:Id', component: notesSettings, data: { displayName: 'Notifications' } }
]
}
];
@NgModule导入:
imports: [ BrowserModule, RouterModule, CommonModule, FormsModule, ReactiveFormsModule, HttpModule, routing, RouterModule.forChild(settingsRoute) ],
答案 0 :(得分:2)
较新的路由器不再支持terminal
属性。拿出来,一切都应该建立。
答案 1 :(得分:0)
删除终端属性并尝试实施此处显示的内容
children: [
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
...
]