【问题标题】:Ionic 4 page navigationIonic 4 页面导航
【发布时间】:2019-11-26 23:10:34
【问题描述】:

我正在尝试使用 ionic 4 创建一个应用程序。最初,我需要在一个屏幕和另一个屏幕之间导航(从第 1 页转到第 2 页)。但是,我总是会弹出以下错误:

Uncaught (in promise): Error: No component factory found for Page2. Did you add it to @NgModule.entryComponents?
Error: No component factory found for Page2. Did you add it to @NgModule.entryComponents?

我的 page1.html:

<ion-header>
  <ion-navbar>
    <button ion-button menuToggle>
      <ion-icon name="menu"></ion-icon>
    </button>
    <ion-title>Page One</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <ion-label id="textView">Oi, Fulano!</ion-label>
  <button (click)='outraPagina();' id="btnTrocar">Trocar usuário</button>
</ion-content>

我的 page1.ts:

import { Component } from '@angular/core';
import { IonicPage, NavController } from 'ionic-angular';
import { Page2 } from '../page2/page2'

@IonicPage()
@Component({
  selector: 'page-page1',
  templateUrl: 'page1.html'
})
export class Page1 {
  constructor(public navCtrl: NavController) {

  }

  outraPagina() {
    this.navCtrl.push(Page2, {});
  }

}

关于如何解决的任何想法? 谢谢。

【问题讨论】:

    标签: ionic-framework ionic4


    【解决方案1】:

    需要在app.module.ts中添加page2

      declarations: [
        AppComponent,
        page2
      ],
      entryComponents: [page2],
    

    【讨论】:

    • 谢谢!完美运行!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 2022-01-17
    • 2018-04-23
    • 1970-01-01
    • 2019-11-06
    • 2023-03-12
    • 1970-01-01
    相关资源
    最近更新 更多