1. 创建组件

ionic g component myComponent

myComponent为组件名称

创建好后,生成的文件如下图

Ionic 3 自定义组件的使用

 

 2. 在Page 中使用

使用的是home

在home.html加入

1
2
3
<ion-content padding>
  <my></my>
</ion-content>

2.1 在home.module.ts中加入Components 

Ionic 3 自定义组件的使用

 2.2 或者在home.module.ts 的declarations中加入MyComponent

Ionic 3 自定义组件的使用

 

 



本文转自Work Hard Work Smart博客园博客,原文链接:http://www.cnblogs.com/linlf03/p/7699969.html,如需转载请自行联系原作者

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-18
  • 2021-12-11
  • 2022-12-23
  • 2021-04-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-05
  • 2021-12-16
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案