2
AM設置模塊在我的路由,我想設置默認路由,但它不能Angular2設置默認路由
這是路由模塊
const appRoutes: Routes = [
{ path: 'login', component: LoginComponent, useAsDefault:true }, //returns an error
{
path: 'dash',
redirectTo:"dashboard"
},
{ path: 'reset-password', component: ResetPasswordComponent },
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
{ path: '**', component: PageNotFoundComponent }
];
以上返回
錯誤LoginComponent; useAsD...' is not assignable to type 'Route[]'
什麼可能是錯的
請看看http://stackoverflow.com/questions/37605119/angular2-router-angular-router-how-to-set-default-route –
有什麼不對?你有錯誤的清晰的反應;)因爲路由器沒有'useAsDefault'屬性,檢查它:https://angular.io/docs/ts/latest/api/router/index/Route-interface.html – Daredzik