ionic2中ion-segment用法

segment是一组按钮,有时称为分段控件,允许用户与许多控件的紧凑组进行交互。 分段提供与标签相似的功能,选择一个将取消选择所有其他选项。 当您希望让用户在应用程序的不同页面之间来回移动时,应使用选项卡栏而不是分段控件。 您可以使用Angular的ngModel或FormBuilder API。

效果看图看代码:



    
        [(ngModel)]="icons" color="secondary">
            value="camera">
                name="camera">带iocn
            
            value="bookmark">
                头部使用Segment
                name="bookmark">
            
        
    



[(ngModel)]="relationship" color="primary" (ionChange)="segmentChanged($event)">
    value="friends">
        Segment 在内容里面使用
    
    value="enemies">
        可以绑定一个事件(ionChange)
    



[formGroup]="myForm"> formControlName="mapStyle" color="danger"> value="standard"> Standard value="hybrid"> 表单内使用 value="sat"> Satellite
[(ngModel)]="change"> value="apple"> 苹果 value="pie">
[ngSwitch]="change">
*ngSwitchCase="'apple'"> 苹果显示,如果要默认显示一个就把默认的那个设置一个初始值比如要默认显示苹果就把苹果的value值设置成change也就是说,在定义change变量的时候,需要把哪个设置为默认显示就把哪个的value值赋值给change作为初始值 public change="pie";
*ngSwitchCase="'pie'"> 梨显示
效果: ionic2中ion-segment用法_第1张图片 ionic2中ion-segment用法_第2张图片 ionic2中ion-segment用法_第3张图片

参照文档:https://ionicframework.com/docs/api/components/segment/Segment/

样式

Sass變量

iOS  材料設計  Windows平台
屬性 默認 描述
$segment-button-ios-background-color transparent

分段按鈕的背景

$segment-button-ios-background-color-activated $toolbar-ios-active-color

激活的段按鈕的背景

$segment-button-ios-text-color color-contrast($colors-ios, $segment-button-ios-background-color-activated)

段按鈕的文本顏色

$segment-button-ios-transition-activated 100ms all linear

激活的段按鈕的轉換

$segment-button-ios-transition-hover 100ms all linear

盤旋按鈕的切換

$segment-button-ios-transition-active 100ms all linear

按按鈕切換分段按鈕

$segment-button-ios-opacity-hover .1

懸停的細分按鈕的不透明度

$segment-button-ios-opacity-active .16

按下分段按鈕的不透明度

$segment-button-ios-opacity-activated 1

激活的段按鈕的不透明度

$segment-button-ios-opacity-disabled .3

禁用段的不透明度按鈕

$segment-button-ios-border-width 1px

段按鈕的邊框寬度

$segment-button-ios-height 3.2rem

段按鈕的高度

$segment-button-ios-line-height 3rem

分段按鈕的線高度

$segment-button-ios-font-size 1.3rem

段按鈕的字體大小

$segment-button-ios-border-radius 4px

分段按鈕的邊框半徑

$segment-button-ios-icon-size 2.6rem

細分按鈕中圖標的大小

$segment-button-ios-icon-line-height 2.8rem

段按鈕中圖標的線高度

$segment-button-ios-toolbar-button-max-width 100px

工具欄中段按鈕的最大寬度

$segment-button-ios-toolbar-button-height 2.6rem

工具欄中的段按鈕的高度

$segment-button-ios-toolbar-line-height 2.5rem

工具欄中的段按鈕的線高度

$segment-button-ios-toolbar-font-size 1.2rem

工具欄中的段按鈕的字體大小

$segment-button-ios-toolbar-icon-size 2.2rem

工具欄中“段”按鈕中圖標的大小

$segment-button-ios-toolbar-icon-line-height 2.4rem

工具欄中的段按鈕中圖標的線高度


你可能感兴趣的:(ionic)