Skip to content

Commit

Permalink
feat(components): [switch] 新增阻止切换钩子
Browse files Browse the repository at this point in the history
  • Loading branch information
Ce1ling committed Oct 4, 2023
1 parent 942090e commit 61bbb45
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/components/Switch/Switch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions packages/components/Switch/switch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface SwitchProps {
offIcon?: string
width?: string
size?: ViBaseSizes
beforeChange?: () => boolean
}

export interface SwitchEmits {
Expand Down

0 comments on commit 61bbb45

Please sign in to comment.