Skip to content
On this page

组件库文档 tmui.design

分段器选项卡 Segtab

分段选择/切换器,常用于直观的单项菜单、选项选值切换。


🌶️ 分段器选项卡 Segtab 示例

查看模拟效果
示例模板
vue
<template>
    <tm-app>
        <tm-sheet >
            <tm-text :fontSize="24" _class="font-weight-b" label="基础属性,更多玩法请前往文档。"></tm-text>
            <tm-divider></tm-divider>
            <tm-segtab :width="636" :list="list" defaultValue="2"></tm-segtab>
        </tm-sheet>
        <tm-sheet >
            <tm-text :fontSize="24" _class="font-weight-b" label="改变按钮主题"></tm-text>
            <tm-divider></tm-divider>
            <tm-segtab :round="24" :width="636" color="primary"  activeColor="white" :list="list" defaultValue="2"></tm-segtab>
        </tm-sheet>
        <tm-sheet >
            <tm-text :fontSize="24" _class="font-weight-b" label="背景"></tm-text>
            <tm-divider></tm-divider>
            <tm-segtab :round="24" :width="636" bgColor="primary" :followDark="false" color="white" activeColor="primary" :list="list" defaultValue="2"></tm-segtab>
        </tm-sheet>
        <tm-sheet >
            <tm-text :fontSize="24" _class="font-weight-b" label="渐变"></tm-text>
            <tm-divider></tm-divider>
            <tm-segtab :round="24" :width="636" bgColor="green" :followDark="false" linear="right" color="white" activeColor="green" :list="list" defaultValue="2"></tm-segtab>
        </tm-sheet>
    </tm-app>
</template>
<script lang="ts" setup>
import { ref, getCurrentInstance } from "vue"
import { onShow, onLoad } from "@dcloudio/uni-app";
import tmApp from "@/tmui/components/tm-app/tm-app.vue"
import tmSheet from "@/tmui/components/tm-sheet/tm-sheet.vue"
import tmText from "@/tmui/components/tm-text/tm-text.vue"
import tmSegtab from "@/tmui/components/tm-segtab/tm-segtab.vue"
import tmDivider from "@/tmui/components/tm-divider/tm-divider.vue"
const list = ref([
    {text:'苹果',id:'1'},
    {text:'菠萝菠萝密',id:'2'},
    {text:'香蕉',id:'3'},
    {text:'火龙果',id:'4'},
    {text:'tmui',id:'5'},
])
</script>

🌶️ 兼容性

APP-VUEAPP-NVUE小程序WEB/H5VUE3/TS
✔️✔️✔️✔️✔️

🌱 参数

本组件含有公共属性 公共属性

参数名类型默认值描述
widthNumber600宽度,单位rpx
heightNumber64高度,单位rpx
gutterNumber2
listArray[]分段器选项的数据
modelValue[Number,String]0v-model可以是index索引也可是对象id
defaultValue[Number,String]0默认是顺序index值,如果想以字段id来达到index选中效果。需要list为对象,并且提供唯一标识id字段。
beforeChange[Function,Boolean]false在点击切换之前执行,返回false阻止切换,可以是Promise
colorString'white'字体颜色
bgColorString'grey-3'背景颜色
fontSizeNumber24字体大小
activeColorString'primary'被选中后的文字色

list[]数据格式:

ts
[
    {
        text:number|string,
        id:number|string,
        [prop:string]:any
    }
]

🌹 事件

事件名参数返回数据描述
update:modelValuevalue
changevalue当点击项目时触发,返回listitem数据
clickindex点击事件

🌽 slot插槽

🥗 ref方法

方法名参数返回值描述

😡 贡献者:小超1263375375