ionic3.x - Create a page (page)

Create page: execute the project root directory   ionic g page [pageName]

Introduced in app.module.ts

 

// page custom components
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';
import { NewsPage } from "../pages/news/news"
@ NgModule ({
  Declarations: [    / * declare components * /
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage,
    NewsPage
  ],
  imports: [  /*引入的模块 依赖的模块*/
    BrowserModule,
    ComponentsModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],  /*启动的模块*/
  entryComponents: [   /*配置不会在模板中使用的组件*/
    MyApp,
    AboutPage,
    ContactPage,
    HomePage,
    TabsPage,
    NewsPage
  ],
  providers: [   /*配置服务*/
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

 


 

页面跳转:

1. 直接在要跳转的页面使用ionic 的 NavController

step1: 引入 page

step2:  调用 this.navCtrl.push(pageName)    pageName -- page 的类名

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { NewsPage } from '../news/news'
@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  constructor(public navCtrl: NavController) {
  }
  goNews() {
    this.navCtrl.push(NewsPage)
  }
}

 

Guess you like

Origin www.cnblogs.com/monkey-K/p/11644649.html