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

查看:723
本文介绍了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- *组件,因为我没有导入 IonicModule.forRoot(..)在我的components.module中。

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(..)

另请注意Angular的 CommonModule 也是制作Angular指令的必要条件ork,所以你可能也需要导入它。

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天全站免登陆