1
試圖創建Angular2一個簡單的路由:Angular2 - 路由錯誤 - 類型 '串' 不分配鍵入 '<any>類型'
ERROR在 C:/項目/遊戲化/ src目錄/程序/應用程序。 routing.ts(8,7):
Type '({ path: string; redirectTo: string; pathMatch: string; } |
{ path: string; component: string; })[]'
is not assignable to type 'Route[]'.
Type '{ path: string; redirectTo: string; pathMatch: string; } |
{ path: string; component: string; }' is not assignable to type 'Route'.
Type '{ path: string; component: string; }' is not assignable to type 'Route'.
Types of property 'component' are incompatible.
Type 'string' is not assignable to type 'Type<any>'
app.routing.ts如下:
const routes: Routes = [
{ path: '', redirectTo:'/login', pathMatch: 'full' },
{ path: 'explorer', component:'ExplorerQuizComponent' },
{ path:'login', component: 'LoginComponent'}];
@NgModule({imports: [ RouterModule.forRoot(routes) ], exports: [ RouterModule ]})`
謝謝@汪史蒂文。它現在有效。 –