小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

ionic3學(xué)習(xí)筆記(五)

 liang1234_ 2019-01-15

下面是最近整理的一篇ionic3左側(cè)菜單欄的文章。

1,新建一個(gè)空白項(xiàng)目 ionic start  myApp blank

2, 要在模板中添加一個(gè)切換菜單,所以在模板中添加一個(gè)指令按鈕menuToggle(我這里的按鈕在HomePage導(dǎo)航欄上,這里HomePage也是項(xiàng)目項(xiàng)目初始化加載的初始頁(yè)面(根頁(yè)面))

  1. <button ion-button menuToggle icon-only>
  2. <ion-icon name='ios-menu-outline'></ion-icon>
  3. </button>

注意:如果MenuToggle按鈕添加到導(dǎo)航欄頁(yè)面,當(dāng)它所在頁(yè)面目前還是根頁(yè)面的按鈕才會(huì)出現(xiàn)或者頁(yè)面是應(yīng)用程序中加載的初始頁(yè)面,或者是使用NavController上的setRoot方法設(shè)置為根頁(yè)面的頁(yè)面。

3,創(chuàng)建菜單頁(yè)面(這里我是在app.html)

    (1)菜單組件是從當(dāng)前視圖的側(cè)面滑入的導(dǎo)航抽屜。默認(rèn)情況下,它從左側(cè)滑入。

     (2)這里用[content]="content" 一個(gè)局部變量,將menu 添加到<ion-nav>上。

  1. <ion-menu [content]="content">
  2. <ion-content>
  3. <!-- div header :里面是我編寫的一個(gè)菜單頁(yè)面的頭部,一般情況下可以省掉 -->
  4. <div class="menu-header">
  5. <!-- onerror: 事件會(huì)在文檔或圖像加載過程中發(fā)生錯(cuò)誤時(shí)被觸發(fā)。 -->
  6. <div class="user-avatar ">
  7. <img [src]="chosenPicture || placeholder" onerror="this.src='assets/imgs/musicList1.jpg'" />
  8. </div>
  9. <div menuClose *ngFor="let p of butPages;let i=index">
  10. <div class="myname" (click)="openPage(p)" *ngIf="i==0">我-丹</div>
  11. <div class="grade" (click)="openPage(p)" *ngIf="i==1">lv.4</div>
  12. <div class="grade1" (click)="openPage(p)" *ngIf="i==2">
  13. 簽到 >
  14. </div>
  15. </div>
  16. </div>
  17. <!-- div menuList:是主要的菜單部分,這部分是菜單重點(diǎn) -->
  18. <div class="menu-list">
  19. <!-- no-lines:取消list的默認(rèn)線條 -->
  20. <ion-list no-lines>
  21. <button menuClose="left" ion-item *ngFor="let p of pages;let i=index" (click)="openPage(p)">
  22. <ion-icon name="{{p.icon}}" item-left class="iconColor"></ion-icon>
  23. {{p.title}}
  24. </button>
  25. </ion-list>
  26. </div>
  27. </ion-content>
  28. <!--footer: 是這個(gè)菜單頁(yè)面的底部也可以省略 -->
  29. <ion-footer>
  30. <div class="menu-footer">
  31. <ion-grid>
  32. <ion-row >
  33. <ion-col col-4 *ngFor="let f of footerBtn">
  34. <button ion-button clear >
  35. <ion-icon name="{{f.icon}}" item-left class="iconColor" ></ion-icon> 
  36. {{f.title}}
  37. </button>
  38. </ion-col>
  39. </ion-row>
  40. </ion-grid>
  41. </div>
  42. </ion-footer>
  43. </ion-menu>
  44. <ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>

3.ts文件里對(duì)菜單做一些數(shù)據(jù)的初始化

import { Component, ViewChild } from '@angular/core';
import { Platform, Nav, NavController, NavParams } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

import { HomePage } from '../pages/home/home';
import { PageOnePage } from '../pages/page-one/page-one';
import { PageTwoPage } from '../pages/page-two/page-two';
import { PageThreePage } from '../pages/page-three/page-three';
import { MyInfoPage } from '../pages/my-info/my-info';
import { MyGradePage } from '../pages/my-grade/my-grade';
@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  footerBtn;
  // 父組件中使用@ViewChild拿到子組件的變量和方法(父組件可調(diào)用子組件的方法和變量)
  // 這里引入的是app.html <ion-nav>
  @ViewChild(Nav) nav: Nav;
  rootPage=HomePage;
  placeholder = 'assets/imgs/header-logo.jpg';
  chosenPicture: any;
  butPages;
  pages;
  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
    });
    this.initPages();
    this.initButPages();
    this.initfooter();

  }

  initPages(){
    this.pages=[
      {title:'我的消息',component: PageOnePage,icon:'ios-mail-outline'},
      {title:'我的好友',component: PageThreePage,icon:'ios-contact-outline'},
      {title:'附近的人',component: PageThreePage,icon:'ios-pin-outline'},
      {title:'商城',component: PageThreePage,icon:'ios-cart-outline'},
      {title:'聽歌識(shí)別',component: PageThreePage,icon:'ios-mic-outline'},
      {title:'定時(shí)停止播放',component: PageThreePage,icon:'ios-clock-outline'},
      {title:'掃一掃',component: PageThreePage,icon:'ios-qr-scanner-outline'},
      {title:'音樂鬧鐘',component: PageThreePage,icon:'ios-alarm-outline'},
      {title:'駕駛模式',component: PageThreePage,icon:'ios-car-outline'},
      {title:'個(gè)性換膚',component: PageThreePage,icon:'ios-shirt-outline'},
      {title:'音樂云盤',component: PageThreePage,icon:'ios-cloudy-outline'}
    ]
  }

  initButPages(){
    this.butPages=[
      {title:'my info',component: MyInfoPage},
      {title:'my grade',component: MyGradePage},
      {title:'my grade',component: MyGradePage}
    ]
  }
  openPage(page) {
    this.nav.push(page.component);
  }
  initfooter(){
    this.footerBtn=[
      {title:'夜間',icon:'ios-moon-outline'},
      {title:'設(shè)置',icon:'ios-settings-outline'},
      {title:'退出',icon:'ios-power-outline'},
    ]
  }
}


4,到這里已經(jīng)差不多完成了,下面是一些css樣式設(shè)計(jì)

  1. .menu-header{
  2. background-image: url(../assets/imgs/musicList2.jpg);
  3. height:28%;
  4. }
  5. .user-avatar {
  6. padding-top:11%;
  7. padding-left:6%;
  8. }
  9. .user-avatar img{
  10. width: 27%;
  11. height: 26%;
  12. border-radius:50%;
  13. }
  14. .myname{
  15. padding-left: 6%;
  16. font-family: KaiTi;
  17. color:white;
  18. font-size: 1.2em;
  19. display: block;
  20. float: left;
  21. margin-right: 4%;
  22. padding-top:6px;
  23. }
  24. .grade{
  25. height: 16px;
  26. width: 30px;
  27. border: white 1px solid;
  28. font-family: KaiTi;
  29. font-size: 0.8em;
  30. text-align: center;
  31. color: white;
  32. border-radius:8px;
  33. display: block;
  34. margin-top:9px;
  35. float: left;
  36. }
  37. .grade1{
  38. height: 22px;
  39. width: 60px;
  40. border: white 1px solid;
  41. font-family: KaiTi;
  42. font-size: 0.8em;
  43. color: white;
  44. border-radius: 8px;
  45. display: block;
  46. float: right;
  47. margin-right:5%;
  48. margin-top:5px;
  49. text-align: center;
  50. line-height: 22px;
  51. }
  52. .menu-list{
  53. padding-top:3%;
  54. height: 64%;
  55. }
  56. .menu-footer button{
  57. color: black;
  58. }
  59. .iconColor{
  60. color: gray;
  61. }


下面是我的完成界面。





如果有什么不足請(qǐng)多多指教

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多