Ionic5 Prod生成错误-未知组件 [英] Ionic5 prod build error - unknown component
问题描述
我对 ionic电容器build --prod ios
的问题是,我的工作组件始于
My issue with ionic capacitor build --prod ios
is that my working components starting with the likes of
<ion-content>
<ion-grid class="ion-no-padding">
<ion-row>
<ion-col>
构建失败
'ion-grid' is not a known element:
1. If 'ion-grid' is an Angular component, then verify that it is part of this module.
2. If 'ion-grid' is a Web Component then add 'CUSTOM_ELEMENT
如果没有-prod
,它可以正常工作.但是,如果没有-prod
,我将无法成功运行
Without the --prod
it works fine. However, without the --prod
I am not able to sucessfully run
import { Component, enableProdMode } from '@angular/core';
...
try{
enableProdMode();
}catch{
this.logger.logError('Prod Mode Failed');
}
我设法通过将 angular.json
中的 aot
和 buildOptimizer
设置为来构建-prod
错误
I managed to get --prod
to build with setting aot
and buildOptimizer
in angular.json
to false
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
但是,这似乎使-prod
不相关?至少 enableProdMode
仍然失败...?
However, this seems to make the --prod
irrelevant? At least enableProdMode
is still failing... ?
在建议的此处添加 CUSTOM_ELEMENTS_SCHEMA
/a>也没有任何区别.
Adding CUSTOM_ELEMENTS_SCHEMA
like proposed here has not made any difference either.
推荐答案
通过将 IonicModule
导入到我的组件模块中解决了该问题.
Solved it by importing IonicModule
into my component moduels. The boilerplate code from the ionic generate
does not include this.
@NgModule({
imports: [
CommonModule,
IonicModule,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA]
这篇关于Ionic5 Prod生成错误-未知组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!