1
我有一個角度爲2的應用程序,寫入角度2測試版14.我將其升級到rc5。我使用的是最新的路由器,我的包JSON包含"@angular/router": "3.0.0-rc.1"
在設置路線時使用角度2中的名稱
以前的路線進行了配置,如:
{path:'/...',name:'LoggedIn',component:LoggedInComponent},
{path:'/auth', name:'Auth', component:AuthComponent}
我現在做這樣的
import { RouterModule , Routes } from '@angular/router';
import {AuthComponent} from "./auth/auth.component";
import {LoggedInComponent} from "./auth/logged-in.component";
import {LOGGED_IN_ROUTES} from "./auth/logged-in.routes";
const APP_ROUTES : Routes = [
{ path : '/...' , name :'LoggedIn' , component : LoggedInComponent , children : LOGGED_IN_ROUTES},
{ path : '' , component : AuthComponent},
{ path : 'auth' , component : AuthComponent},
];
export const routing = RouterModule.forRoot(APP_ROUTES);
我收到錯誤,如
Type '({ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; } | { path...' is not assignable to type 'Route[]'.
Type '{ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; } | { path:...' is not assignable to type 'Route'.
Type '{ path: string; name: string; component: typeof LoggedInComponent; children: Route[]; }' is not assignable to type 'Route'.
Object literal may only specify known properties, and 'name' does not exist in type 'Route'.
從你的路由配置中刪除'name' ... –