0

我正在使用 angular7 并为管理员进行路由,但它给出错误'字符串不可分配给类型'任何人都可以告诉这个错误是什么以及我该如何解决它?

错误截图:-

在此处输入图像描述

管理员路由.ts

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { adminComponent } from './admin.component';

const routes:  Routes =[
    {
        path: 'admin',
        component:adminComponent,
        children: [
            {path: '', component: 'loginComponent', pathMatch: 'full'},
            {path: 'dashboard', component: 'dashboardComponent'}
            //{path: 'login', component: 'loginComponent'}
        ]
    }
];

export const adminComponents = [
    adminComponent
];

@NgModule({
    imports: [RouterModule.forChild(routes)],
    exports: [RouterModule]
})

export class adminRouterModule{

}
4

2 回答 2

1

从...除去component: loginComponent

{path: '', component: loginComponent, pathMatch: 'full'},
{path: 'dashboard', component: dashboardComponent}
于 2018-10-26T05:40:24.390 回答
0

您的组件不应该是 a string,它是component名称,

改变

  {path: 'dashboard', component: 'dashboardComponent'}

  {path: 'dashboard', component: dashboardComponent}
于 2018-10-26T05:40:05.613 回答