相关疑难解决方法(0)

断言错误:传入的类型不是 ComponentType,它没有“?cmp”属性

每当应用程序运行时,我都会收到此错误,尽管在当前开发中不会给我带来问题(我认为)我想了解此错误并知道它来自何处,因为我完全迷失了,我什至无法发布相关信息代码。但我会努力的。。

所以这些是主要路线(appModule):

const routes: Routes = [
  {path:'home', component:HomeComponent, canActivate:[AuthGuardService]},
  {path:'detail/:id', component:DetailComponent},
  {path: 'register', component: RegisterComponent},
  {path:'login', component: LoginComponent},
  {path:'', redirectTo:'login', pathMatch: 'full'},
  {path:'**',  redirectTo:'login'}

];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
Run Code Online (Sandbox Code Playgroud)

我有一个核心模块,其中所有组件都已注册,我正在导入RouterModule.forChild([])

@NgModule({
  declarations: [HomeComponent, DetailComponent, RegisterComponent, LoginComponent],
  imports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    RouterModule.forChild([])
  ]
})
export class CoreModule { }
Run Code Online (Sandbox Code Playgroud)

package.json:

{
  "name": "mat-shop",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng …
Run Code Online (Sandbox Code Playgroud)

routes nested-routes angular

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

angular ×1

nested-routes ×1

routes ×1