Ionic framework 如何解决';离子项目';不是离子液体中的已知元素
我正在用ionic构建一个应用程序,我注意到,当我想将我的应用程序转换为apk时,ionic元素(如Ionic framework 如何解决';离子项目';不是离子液体中的已知元素,ionic-framework,Ionic Framework,我正在用ionic构建一个应用程序,我注意到,当我想将我的应用程序转换为apk时,ionic元素(如离子标题、离子标题、离子列表等)会在模式中停止工作。它适用于除模式页面之外的其他页面 async CommentModal(id) { const modal = await this.modalController.create({ component: CommentPage, componentProps:{id}, swipeToCl
离子标题、离子标题、离子列表等)会在模式中停止工作。它适用于除模式页面之外的其他页面
async CommentModal(id) {
const modal = await this.modalController.create({
component: CommentPage,
componentProps:{id},
swipeToClose: true,
cssClass: 'comment-modal'
});
await modal.present();
return
}
下面是comment.module.ts的代码
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgxEmojModule } from 'ngx-emoj';
import { TimeAgoPipe } from 'time-ago-pipe';
import { CommentPageRoutingModule } from './comment-routing.module';
import { CommentPage } from './comment.page';
import { PipesModule } from '../../pipes/pipes.module';
@NgModule({
imports: [
CommonModule,
NgxEmojModule,
PipesModule,
FormsModule,
IonicModule,
CommentPageRoutingModule
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [
CommentPage,
TimeAgoPipe]
})
export class CommentPageModule {}
我在应用程序模块和页面模块中都添加了自定义元素\u模式
,但它不仅仅起作用
这是comment.page.html
<ion-header class="ion-no-border" *ngIf="!isLoading">
<ion-toolbar>
<ion-title class="centerAM">{{no_comm | shortNumber}} comment{{no_comm>1?'s':''}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
....
这是comment.page.html页面
<ion-header class="ion-no-border" *ngIf="!isLoading">
<ion-toolbar>
<ion-title class="centerAM">{{no_comm | shortNumber}} comment{{no_comm>1?'s':''}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ng-container *ngIf="isLoading; else loadTemp;">
.....
</ng-container>
<ng-template #loadTemp>
<ion-item *ngFor="let comm of comms" lines="none">
....
</ion-item>
</ng-template>
</ion-content>
<ion-footer *ngIf="isLoggedIn">
<ion-toolbar>
<ng-container *ngIf="showEm">
....
</ng-container>
<ion-grid>
<ion-row>
.....
</ion-row>
</ion-grid>
</ion-toolbar>
</ion-footer>
{{no_comm | shortNumber}}注释{{{no_comm>1?'s':''}
.....
....
....
.....
请注意,我在做什么,这是错误的加载模态作为延迟加载页面的一部分需要以下几点:
将CommentPageModule导入延迟加载的模式主机页模块
确保CommentPage是CommentPageModule的声明和entryComponents数组的一部分
确保没有任何路由试图延迟加载您的CommentPageModule,因为Ionic 4+中的模块本身不是延迟加载的,它们被打包到可以延迟加载的宿主页面模块中
错误本身意味着IonicModule在实例化时不可用于CommentPage模式。这意味着模块文件中modal(无论页面启动modal)的“主机”必须导入CommentPageModule
如果您需要进一步帮助,请共享延迟加载的主机页的模块文件。您是否在AppModule或打开模型的单个页面模块中添加了CommentPageModule?我正在延迟加载它到延迟加载的模块中,您需要导入CommentPageModule请共享代码,了解您延迟加载组件的确切程度。如果是模态-模态不能延迟加载,它们将与导入它们的组件一起延迟加载。@SergeyRudenko我已经更新了代码
<ion-header class="ion-no-border" *ngIf="!isLoading">
<ion-toolbar>
<ion-title class="centerAM">{{no_comm | shortNumber}} comment{{no_comm>1?'s':''}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ng-container *ngIf="isLoading; else loadTemp;">
.....
</ng-container>
<ng-template #loadTemp>
<ion-item *ngFor="let comm of comms" lines="none">
....
</ion-item>
</ng-template>
</ion-content>
<ion-footer *ngIf="isLoggedIn">
<ion-toolbar>
<ng-container *ngIf="showEm">
....
</ng-container>
<ion-grid>
<ion-row>
.....
</ion-row>
</ion-grid>
</ion-toolbar>
</ion-footer>