您好,欢迎来到汇意旅游网。
搜索
您的当前位置:首页ionic组件-segment分段式导航

ionic组件-segment分段式导航

来源:汇意旅游网

效果展示:

Ts代码:

import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-news',
  templateUrl: './news.page.html',
  styleUrls: ['./news.page.scss'],
})

export class NewsPage implements OnInit {

  //定义一个tab
  public tab="tab3";

  constructor() { }

 ngOnInit() {}

  segmentChanged($event){
    console.log('$event');
  }

}

Html代码:

  <!--【ion-segment】可以进行双向数据绑定,加载时,首先判断下面的内容谁等于tab的值,默认显示谁的值-->
  <ion-segment [(ngModel)]="tab">
    <ion-segment-button value="tab1">
      <ion-label>分段式导航1</ion-label>
    </ion-segment-button>
    <ion-segment-button value="tab2">
      <ion-label>分段式导航2</ion-label>
    </ion-segment-button>
    <ion-segment-button value="tab3">
      <ion-label>分段式导航</ion-label>
    </ion-segment-button>
  </ion-segment>

  <!--数据绑定查看tab的内容-->
  <p> {{tab}} </p>

<!--采用【ngSwitch】的方法进行分段式导航的内容切换-->
 <div [ngSwitch]="tab">
    <section *ngSwitchCase="'tab1'">
      分段式导航内容1----注意写法*ngSwitchCase="'tab1'"
    </section>
    <section *ngSwitchCase="'tab2'">
      分段式导航内容2
    </section>
    <section *ngSwitchCase="'tab3'">
      分段式导航内容3
    </section>
  </div>

 

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- hids.cn 版权所有 赣ICP备2024042780号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务