Ionic 3 不能在我的自定义组件中使用 ion-* 组件 [英] Ionic 3 can't use ion-* components inside my custom components

查看:21
本文介绍了Ionic 3 不能在我的自定义组件中使用 ion-* 组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近从 Ionic 2 升级到 Ionic 3,我创建了 components.module.ts 文件并声明并导出了我拥有的每个自定义组件,然后在每个页面模块中导入了这个文件我有.

I have recently upgraded to Ionic 3 from Ionic 2, and I created components.module.ts file and declared and exported each custom component I have, and then imported this single file in every page module I have.

所以现在的问题是我不能在自己的组件中使用 ion-* 组件,因为我没有在 components.module 中导入 IonicModule.forRoot(..).

So now the problem is that I can't use ion-* components inside my own components, because I did not imported the IonicModule.forRoot(..) inside my components.module.

错误是:

模板解析错误:'ion-spinner' 不是已知元素..."

"Template parse errors: 'ion-spinner' is not a known element ..."

我做错了什么?

推荐答案

好吧,所以我想出了解决方案:

Alright, so I figured out the solution:

我只需要在 components.module 中导入 IonicModule无需 forRoot(..).

All i needed was to import IonicModule in components.module, without forRoot(..).

还要注意,Angular 的 CommonModule 也是使 Angular 的指令正常工作所必需的,因此您可能也需要导入它.

Also note that Angular's CommonModule is also necessary to make Angular's directives work, so you probably need to import it too.

这篇关于Ionic 3 不能在我的自定义组件中使用 ion-* 组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆