我正在使用angular7,并为管理员进行路由,但其给定错误“字符串无法分配给类型”,谁能知道这是什么错误,我该如何解决?
错误截图:-
admin.routing.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{
}
答案 0 :(得分:1)
从component: loginComponent
删除
{path: '', component: loginComponent, pathMatch: 'full'},
{path: 'dashboard', component: dashboardComponent}
答案 1 :(得分:0)
您的组件不应为 string
,它是 component
名称
更改
发件人
{path: 'dashboard', component: 'dashboardComponent'}
收件人
{path: 'dashboard', component: dashboardComponent}