zjk
2026-09-29 54dcf0a82e7490fa58b1c056d5c0b9cb739c2931
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { ExtractPropTypes, PropType } from 'vue';
import { baseProps } from '../common/props';
import { getColor } from '../../';
 
/**
 * SwitchProps 开关选择器 props 类型定义
 * @description 选择开关,支持自定义颜色、尺寸、值等
 */
export const SwitchProps = {
    ...baseProps,
    /** 是否显示加载中状态 */
    loading: { type: Boolean, default: false },
    /** 是否禁用 */
    disabled: { type: Boolean, default: false },
    /** 开关尺寸,单位rpx */
    size: { type: [Number, String] as PropType<number | string>, default: 50 },
    /** 打开时的颜色 */
    activeColor: { type: String, default: () => getColor('primary') },
    /** 关闭时的颜色 */
    inactiveColor: { type: String, default: 'var(--u-white-color)' },
    /** v-model 绑定值,是否选中 */
    modelValue: { type: Boolean, default: false },
    /** 是否开启轻微震动反馈 */
    vibrateShort: { type: Boolean, default: false },
    /** 打开时的值 */
    activeValue: { type: [Number, String, Boolean] as PropType<number | string | boolean>, default: true },
    /** 关闭时的值 */
    inactiveValue: { type: [Number, String, Boolean] as PropType<number | string | boolean>, default: false }
};
 
export type SwitchProps = ExtractPropTypes<typeof SwitchProps>;