Skip to content

Commit e8b2147

Browse files
vaebekagol
authored andcommitted
fix(switch): 组件 size 的优先级(DevCloudFE#1199
1 parent 7989c25 commit e8b2147

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/devui-vue/devui/switch/src/switch-types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ export const switchProps = {
88
default: false,
99
},
1010
size: {
11-
type: String as PropType<SwitchSize>,
12-
default: 'md',
11+
type: String as PropType<SwitchSize>
1312
},
1413
color: {
1514
type: String,

packages/devui-vue/devui/switch/src/use-switch.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { SwitchProps, UseSwitchFn } from './switch-types';
55
export function useSwitch(props: SwitchProps, ctx: SetupContext): UseSwitchFn {
66
const formContext = inject(FORM_TOKEN, undefined);
77
const switchDisabled = computed(() => formContext?.disabled || props.disabled);
8-
const switchSize = computed(() => formContext?.size || props.size);
8+
9+
const switchSize = computed(() => props.size || formContext?.size || 'md');
10+
911
const canChange = () => {
1012
if (switchDisabled.value) {
1113
return Promise.resolve(false);

0 commit comments

Comments
 (0)