ionic3 懒加载

网友投稿 192 2023-04-19


ionic3 懒加载

ionic3 默认使用了懒加载技术,相较以前预加载的版本,ionic3构建的app在首页加载时间上有较大的优化,但是,ionic3默认每个页面都会对应一个模块,对于页面较多,但是每个模块都很小的应用可能并不怎么合理。于是,尝试将几个小模块合并为几个大的模块。

1. 一个模块对应一个页面:

默认状态下每个页面都会对应一个模块,如果项目之中的页面比较多那么最后构建的项目中的将会看到有很多的 js 。

原setting.module.ts

import { NgModule } from '@angular/core';

import { IonicPageModule } from 'ionic-angular';

import { SettingPage } from './setting';

@NgModule({

declarations: [

SettingPage,

],

imports: [

IonicPageModule.forChild(SettingPage),

],

entryComponents: [

SettingPage,

]

})

export class SettingPageModule {}

2. 一个模块对应多个页面

修改后的setting.module.ts

import { NgModule } from '@angular/core';

import { IonicPageModule } from 'ionic-angular';

import { SettingPage } from './setting';

import {UserPasswordPageModule} from "./user-password/user-password.module";

import {UsernamePageModule} from "./username/username.module";

@NgModule({

declarations: [

SettingPage,

],

imports: [

IonicPageModule.forChild(SettingPage),

//将两个子页面模块引入

UserPasswordPageModule,

UsernamePageModule,

http:// ],

entryComponents: [

SettingPage,

]

})

export class SettingPageModule {}

总结

以上所述是给大家介绍的ionic3 懒加载,希望对大家有所帮助,如果大家有任何疑问请给我留言,会及时回复大家的。在此也非常感谢大家对我们网站的支持!


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:java 判断类实现接口(java 类型判断)
下一篇:微信小程序自定义模态对话框实例详解
相关文章

 发表评论

暂时没有评论,来抢沙发吧~