From 61bbb4505e126a63df00fb794a96ca649062a37c Mon Sep 17 00:00:00 2001 From: Ce1ling <2134045201@qq.com> Date: Wed, 4 Oct 2023 23:56:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(components):=20[switch]=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=98=BB=E6=AD=A2=E5=88=87=E6=8D=A2=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/components/Switch/Switch.vue | 2 ++ packages/components/Switch/switch.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/components/Switch/Switch.vue b/packages/components/Switch/Switch.vue index b0af6ed..e8f20b4 100644 --- a/packages/components/Switch/Switch.vue +++ b/packages/components/Switch/Switch.vue @@ -56,6 +56,8 @@ const switchStyle = computed(() => ({ const toggleChecked = () => { if (props.disabled || props.loading) return + if (props.beforeChange && !props.beforeChange()) return + emit('update:modelValue', !props.modelValue) } diff --git a/packages/components/Switch/switch.ts b/packages/components/Switch/switch.ts index 20a51c5..12a7906 100644 --- a/packages/components/Switch/switch.ts +++ b/packages/components/Switch/switch.ts @@ -13,6 +13,7 @@ export interface SwitchProps { offIcon?: string width?: string size?: ViBaseSizes + beforeChange?: () => boolean } export interface SwitchEmits {