Skip to content
在新窗口打开实时预览

Subsection 分段选择器 ​

用于在少量互斥选项之间快速切换,支持按钮式滑块和描边分段两种模式。

平台兼容性 ​

H5App微信小程序支付宝小程序
√√√√

基础用法 ​

vue
<snake-subsection :list="['待付款', '待发货', '待收货']" :current="current" @change="current = $event" />

对象选项可通过 disabled: true 禁止切换:

vue
<snake-subsection
    mode="subsection"
    :list="[{ name: '全部' }, { name: '已完成' }, { name: '已关闭', disabled: true }]"
    :current="current"
    @update:current="current = $event"
/>

H5 中当前分段可通过 Tab 聚焦,左右方向键会循环切换,并自动跳过禁用选项。

API ​

Props ​

参数说明类型默认值
list字符串或对象选项列表Array<string | { name: string; disabled?: boolean }>[]
current当前选中索引number | string0
mode按钮滑块或描边分段模式button | subsectionbutton
activeColor / inactiveColor激活和未激活文字颜色string主题默认值
fontSize / height字号与组件高度string | number28 / 70
animation / bold滑块动画与激活项加粗booleantrue / true
bgColor / buttonColor按钮模式的轨道和滑块颜色string主题默认值
customClass / customStyle自定义类名和样式string | object | array''

Events ​

事件名触发时机参数
change选中新的可用选项index
update:current选中索引更新index

主题变量 ​

变量名说明
--snake-color-primary激活文字及描边颜色
--snake-color-text-secondary未激活文字颜色
--snake-color-surface-muted按钮模式轨道背景色
--snake-color-surface描边模式背景色
--snake-color-white按钮模式激活文字默认颜色

为 uni-app 商城与 CMS 场景设计