Skip to content

开关 Switch

基本用法

自定义颜色

在不同状态下显示的文本

可以用图标代替文本

可以绑定多种类型的值(string、boolean、number)

API

Switch 参数

参数名说明类型可选值默认值必填
modelValuev-modelboolean/string/numbertruetrue
disabled是否禁用booleanfalse
loading是否加载中booleanfalse
width开关的宽度(px)number35
activeIcon开启状态下的图标(会覆盖 activeLabel)string
inactiveIcon关闭状态下的图标(会覆盖 inactiveLabel)string
activeValue开启状态下的值boolean/string/numbertrue
inactiveValue关闭状态下的值boolean/string/numberfalse
activeLabel开启状态下的文本string
inactiveLabel关闭状态下的文本string
activeColor开启状态下的颜色(必须为 16 进制格式)string#63B931
inactiveColor关闭状态下的颜色(必须为 16 进制格式)string#C91B26

Switch 事件

事件名说明回调参数
change值发生变化时触发(v: activeValue/inactiveValue) => void