1.8 ionic3入门——测滑菜单(side menu)中的界面跳转
生活随笔
收集整理的這篇文章主要介紹了
1.8 ionic3入门——测滑菜单(side menu)中的界面跳转
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
(1)如1.3 所寫,測滑菜單寫在app.html,所以測滑菜單中的各個按鈕的實現就在app.component.ts中寫了,如果像其他普通界面一樣在app.component.ts中引入NavController并在構造函數constructor中聲明public navCtrl:NavController就會報錯,那么,在app.html中正確進行界面跳轉的方法為
(2)引入ViewChild和Nav
(3)聲明
@ViewChild(Nav) nav: Nav;(4)跳轉
this.nav.push(SettingsPage);(5)全部代碼
import { Component,ViewChild } from '@angular/core'; import { Platform,Nav} from 'ionic-angular'; import { StatusBar } from '@ionic-native/status-bar'; import { SplashScreen } from '@ionic-native/splash-screen'; import { TabsPage } from '../pages/tabs/tabs'; import { LoginPage } from '../pages/login/login'; import { SettingsPage } from '../pages/settings/settings'; @Component({ templateUrl: 'app.html' }) export class MyApp { // 父組件中使用@ViewChild拿到子組件的變量和方法(父組件可調用子組件的方法和變量) // 這里引入的是app.html <ion-nav> @ViewChild(Nav) nav: Nav; rootPage:any = TabsPage; constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) { platform.ready().then(() => { statusBar.styleDefault(); splashScreen.hide(); }); } push_mysettings(){ this.nav.push(SettingsPage); } } image.png?
image.png轉載于:https://www.cnblogs.com/sandyLovingCoding/p/9703300.html
總結
以上是生活随笔為你收集整理的1.8 ionic3入门——测滑菜单(side menu)中的界面跳转的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在博文顶部添加文章字数及阅读时间信息:阅
- 下一篇: Git remote 修改源