Home > Web Front-end > JS Tutorial > body text

Introduction to ionic2 lazy loading configuration

巴扎黑
Release: 2017-09-02 13:23:23
Original
1376 people have browsed it

This article mainly introduces the detailed explanation of ionic2 lazy loading configuration. The editor thinks it is quite good. Now I will share it with you and give it as a reference. Let’s follow the editor and take a look.

The title of the article is part 1, and it explains that it can be configured in this way currently, but there may be changes in subsequent use.

Take the ion-cli default home component as an example. Add the home.module.ts file


import { NgModule } from '@angular/core';
import { IonicPageModule } from 'ionic-angular';
import { HomePage } from './home';
@NgModule({
 declarations: [HomePage],
 imports: [IonicPageModule.forChild(HomePage)],
 exports: [HomePage]
})
export class HomePageModule { }
Copy after login

Modify home.ts, mainly to add IonicPage. For its configuration items, please refer to the official documentation.


import { Component } from '@angular/core';
import { IonicPage } from 'ionic-angular';
@IonicPage()
@Component(... )
export class HomePage { ... }
Copy after login

Modify app.component.ts, change HomePage to 'HomePage', delete app.module.ts and the import { HomePage } used in other pages from '.. /pages/home/home'; Because this is no longer needed, just quote the string directly where needed.


rootPage:any = 'HomePage';
Copy after login

ionic serve If you see files similar to the following, it means success.

The above is the detailed content of Introduction to ionic2 lazy loading configuration. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template