Skip to content

引入组件 ​

局部引入

ts
// parent.vue
const FSwitch = defineAsyncComponent(() => import('@/components/formaui/f-switch/f-switch.vue'))

基础用法 ​

checked属性:是否选中(默认false)

html
<f-switch :checked="checked1" @change="val => (checked1 = val)" />

type属性:样式类型(默认switch)

可传入[switch、checkbox]

html
<f-switch type="checkbox" :checked="checked2" @change="val => (checked2 = val)" />

disabled属性:禁用状态

html
<f-switch :checked="true" disabled />
<f-switch :checked="false" disabled />

color属性:switch 选中颜色

html
<f-switch :checked="checked3" @change="val => (checked3 = val)" color="#07C160" />

插槽 ​

名称说明
--

属性 ​

名称类型说明默认值
namestring开关选择器名称''
checkedboolean是否选中false
disabledboolean是否禁用false
typestring样式类型,可传入[switch、checkbox]switch
colorstringswitch 选中颜色-
borderColorstringtype=checkbox 时的边框颜色#ccc
checkMarkColorstringtype=checkbox 时的对号颜色#fff
scaleRationumber|string缩放比例1

事件 ​

事件名说明回调参数
change开关改变事件value: boolean