Angular ';菜单列表';不是延迟加载的已知元素

Angular ';菜单列表';不是延迟加载的已知元素,angular,ionic-framework,ionic3,Angular,Ionic Framework,Ionic3,我在ionic 3.6.1中使用了延迟加载,并得到了跟踪错误。你知道是什么问题吗 “菜单列表”不是已知元素: 1.如果“菜单列表”是一个角度组件,则确认它是该模块的一部分。 2.如果“菜单列表”是Web组件,则将“自定义元素\u架构”添加到此组件的“@NgModule.schemas”以抑制此消息 home.html <menu-list></menu-list> menu-list.ts import { Component } from '@angular/core

我在ionic 3.6.1中使用了延迟加载,并得到了跟踪错误。你知道是什么问题吗

“菜单列表”不是已知元素:
1.如果“菜单列表”是一个角度组件,则确认它是该模块的一部分。
2.如果“菜单列表”是Web组件,则将“自定义元素\u架构”添加到此组件的“@NgModule.schemas”以抑制此消息

home.html

<menu-list></menu-list>
menu-list.ts

import { Component } from '@angular/core';
@Component({
  selector: 'menu-list',
  templateUrl: 'menu-list.html'
})
export class MenuListComponent {

  text: string;

  constructor() {
    console.log('Hello MenuListComponent Component');
    this.text = 'Hello World';
  }

}
components.module.ts(已生成,未修改)


您需要导入导出组件的组件模块,而不是组件本身

查看官方博客。 在home.module.ts中

@NgModule({
  declarations: [
    HomePage,
  ],
  imports: [
    IonicPageModule.forChild(HomePage),
    ComponentsModule //here
  ],
})
export class HomePageModule {}

为什么要在两个模块中导入menulist组件?我不确定它是不是懒洋洋的。查看:在您的
home.module.ts
中,将
MenuListComponent
imports
移动到
declarations
@duanx,它仍然不工作。同样的错误
import { NgModule } from '@angular/core';
import { MenuListComponent } from './menu-list/menu-list';
@NgModule({
    declarations: [MenuListComponent],
    imports: [],
    exports: [MenuListComponent]
})
export class ComponentsModule {}
@NgModule({
  declarations: [
    HomePage,
  ],
  imports: [
    IonicPageModule.forChild(HomePage),
    ComponentsModule //here
  ],
})
export class HomePageModule {}