离子3,延迟加载标签组件 [英] ionic 3, lazy-loading tabs components

查看:119
本文介绍了离子3,延迟加载标签组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用延迟加载创建一个离子3标签应用,而无需导入组件。

I'm trying to create a ionic 3 tabs app with lazy loading without importing the components .

在我的app.component.ts

in my app.component.ts

 rootPage:string = "Tabs";

tabs.html中的

in tabs.html

<ion-tabs>
<ion-tab [root]="Favorites" tabTitle="fav" tabIcon="star"></ion-tab>
<ion-tab [root]="libaray" tabTitle="Library" tabIcon="book"></ion-tab>
</ion-tabs>

in Favorites.module.ts

in Favorites.module.ts

import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { Favorites } from './favorites';

@NgModule({
  declarations: [
    Favorites,
  ],
  imports: [
    IonicPageModule.forChild(Favorites),
  ],
  exports: [
    Favorites
  ]
})
export class FavoritesModule {}

到目前为止,标签页成功加载但没有查看(空白页)。
我认为我使用[root]属性的问题是延迟加载!
如何修复?

so far , the tabs page loads successfully but no view (blank page) . i think the problem that i'm using [root] attribute with lazy loading ! how to fix that ?

谢谢

推荐答案

查看此处

<ion-tab [root]="Favorites" tabTitle="fav" tabIcon="star"></ion-tab>
<ion-tab [root]="libaray" tabTitle="Library" tabIcon="book"></ion-tab>

这里 libaray 收藏夹需要是组件的变量。

Here libaray and Favorites need to be variables of the component.

在组件中尝试将离子页面的等效字符串设置为中的变量Tabs.ts

In your component try setting string equivalent of the ionic page to the variables in Tabs.ts:

export class Tabs{
 Favorites:any='Favorites';
 libaray:any = 'libaray'; //assuming you tried to give the page class name to `root`.
}

注意:确保 将延迟加载的页面导入页面模块以外的任何位置。

Note: Be sure not to import your lazy loaded pages anywhere other than within the page module.

这篇关于离子3,延迟加载标签组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆