1. 创建component :
1
ionic g component my-component
  1. component必须被封装成为module才能使用,添加一个module:
1
ionic g module my-component
  1. 在 my-component.module.ts中:
1
2
declarations:[my-component]
exports:[my-component]

当在componet module中使用ionic组件,需要 import IonicModule 需要使用ngfor之类的装饰器的话,需要 import CommonModule

Exports all the basic Angular directives and pipes, such as NgIf, NgForOf, DecimalPipe, and so on. Re-exported by BrowserModule, which is included automatically in the root AppModule when you create a new app with the CLI new command.

  1. 在使用的页面的module.ts中
1
imports:[ my-component ]