【问题标题】:This is page jumps with ionic3 [duplicate]这是 ionic3 的页面跳转 [重复]
【发布时间】:2017-09-27 18:00:40
【问题描述】:

我设置了一个标签页,A、B、C。像这样:

tab1Root: any = HomePage;
tab2Root: any = AboutPage;
tab3Root: any = ContactPage;

当我从 PageB 跳转到新的 pageC 网址变为:http://localhost:8102/#/about/shopping; 我重新加载购物页面,我有一个错误:

组件 AboutPage 不是任何 NgModule 的一部分,或者该模块尚未导入您的模块。 我是新人,希望有人能帮助我; 这是我的代码:

关于.ts:

  import { Component } from '';
  import { IonicPage, NavController, NavParams } from 'ionic-angular';
  @ionicpage()
  @component({
   selector: 'page-about',
   templateUrl: 'about.html',
  })
  export class AboutPage {
  lists = Lists
  constructor(public navCtrl: NavController, public navParams: 
   NavParams) {}
  ionViewDidLoad() {}
  openPage(page){
    this.navCtrl.push(page)
   }
  }

关于.module.ts

import { NgModule } from '';
import { IonicPageModule } from 'ionic-angular';
import { AboutPage } from './about';
@NgModule({
declarations: [
 AboutPage,
],
imports: [
 IonicPageModule.forChild(AboutPage),
],
})
export class AboutPageModule {}

【问题讨论】:

  • @SURAJ 我试过了,但是不行
  • 您是否从标签组件页面中删除了页面的导入?
  • emmm....如果我删除了 imports 。该选项卡组件找不到该页面,因此该页面不显示
  • 检查欺骗中的答案..您需要使用字符串等价物..而不是页面对象
  • 嘿!我只是解决了这个问题,只是因为我忘记删除 APP COMPONENT 上的 Imort 。谢了!!!

标签: angular typescript ionic3


【解决方案1】:

我从未使用过标签组件,但在创建新页面时遇到了同样的错误,我没有将其添加到 entryComponents 部分,例如:

import { NgModule } from '';
import { IonicPageModule } from 'ionic-angular';
import { AboutPage } from './about';
@NgModule({
declarations: [
     AboutPage,
],
imports: [
     IonicPageModule.forChild(AboutPage),
],
entryComponents: [
     AboutPage,
]
})

如果您在 EntryComponent 部分声明您的新页面应该可以解决您遇到的问题:

AboutPage 不是任何 NgModule 的一部分,或者该模块尚未导入到您的模块中

根据文档 EntryCompmonents

定义在定义此组件时也应编译的组件。对于这里列出的每个组件,Angular 都会创建一个 ComponentFactory 并将其存储在 ComponentFactoryResolver 中。

【讨论】:

  • 谢谢!我会继续看看如何处理我的问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-10
  • 1970-01-01
  • 2018-05-10
  • 2022-10-15
相关资源
最近更新 更多