ionic3 懶加載
ionic3 默認(rèn)使用了懶加載技術(shù),相較以前預(yù)加載的版本,ionic3構(gòu)建的app在首頁加載時(shí)間上有較大的優(yōu)化,但是,ionic3默認(rèn)每個(gè)頁面都會(huì)對應(yīng)一個(gè)模塊,對于頁面較多,但是每個(gè)模塊都很小的應(yīng)用可能并不怎么合理。于是,嘗試將幾個(gè)小模塊合并為幾個(gè)大的模塊。
1. 一個(gè)模塊對應(yīng)一個(gè)頁面:
默認(rèn)狀態(tài)下每個(gè)頁面都會(huì)對應(yīng)一個(gè)模塊,如果項(xiàng)目之中的頁面比較多那么最后構(gòu)建的項(xiàng)目中的將會(huì)看到有很多的 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. 一個(gè)模塊對應(yīng)多個(gè)頁面
修改后的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), //將兩個(gè)子頁面模塊引入 UserPasswordPageModule, UsernamePageModule, ], entryComponents: [ SettingPage, ] }) export class SettingPageModule {}
總結(jié)
以上所述是小編給大家介紹的ionic3 懶加載,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
JavaScript常見事件處理程序?qū)嵗偨Y(jié)
這篇文章主要介紹了JavaScript常見事件處理程序,結(jié)合實(shí)例形式總結(jié)分析了javascript HTML事件、DOM事件、IE事件等相關(guān)處理程序與操作技巧,需要的朋友可以參考下2019-01-01如何在Web頁面上直接打開、編輯、創(chuàng)建Office文檔
如何在Web頁面上直接打開、編輯、創(chuàng)建Office文檔...2007-03-03javascript得到當(dāng)前頁的來路即前一頁地址的方法
這篇文章主要介紹了javascript得到當(dāng)前頁的來路即前一頁地址的方法,需要的朋友可以參考下2014-02-02JavaScript本地儲(chǔ)存:localStorage、sessionStorage、cookie的使用
這篇文章主要介紹了JavaScript本地儲(chǔ)存:localStorage、sessionStorage、cookie的使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-10-10在網(wǎng)頁里看flash的trace數(shù)據(jù)的js類
我的js類jdhcn.js中的一個(gè)flashDebug方法2009-01-01