Skip to content

TimeSelect 时间选择

规则

基础示例

js
const rule = {
    type: "elTimeSelect",
    field: "time",
    title: "活动时间",
    value: [],
    props: {
        start:"08:30",
        step:"00:15",
        end:"18:30",
    },
}

Props 配置示例

工作时间选择

js
const rule = {
    type: "elTimeSelect",
    field: "workTime",
    title: "工作时间",
    value: "09:00",
    props: {
        start: "09:00",
        end: "18:00",
        step: "00:30",
        placeholder: "请选择时间",
    },
}

包含结束时间

js
const rule = {
    type: "elTimeSelect",
    field: "endTime",
    title: "结束时间",
    value: "18:00",
    props: {
        start: "09:00",
        end: "18:00",
        step: "01:00",
        includeEndTime: true,
        placeholder: "请选择结束时间",
    },
}

限制时间范围

js
const rule = {
    type: "elTimeSelect",
    field: "appointment",
    title: "预约时间",
    value: "10:00",
    props: {
        start: "08:00",
        end: "20:00",
        step: "00:15",
        minTime: "09:00",
        maxTime: "18:00",
        placeholder: "请选择预约时间",
    },
}

Events 事件示例

监听时间变化

js
const rule = {
    type: "elTimeSelect",
    field: "time",
    title: "活动时间",
    value: "09:00",
    props: {
        start: "08:00",
        end: "18:00",
        step: "00:30",
        placeholder: "请选择时间",
    },
    on: {
        change: (value) => {
            console.log('时间改变:', value);
        },
        blur: (event) => {
            console.log('失去焦点:', event);
        },
        focus: (event) => {
            console.log('获得焦点:', event);
        },
        clear: () => {
            console.log('清空时间');
        },
    },
}

完整配置项:Element_TimeSelect

value :String

Props

属性名说明类型默认值
disabled禁用状态booleanfalse
editable文本框可输入booleantrue
clearable是否显示清除按钮booleantrue
includeEndTime是否在选项中包含endbooleanfalse
size输入框尺寸enumdefault
placeholder非范围选择时的占位内容string
name原生属性string
effectTooltip 主题,内置了 dark / light 两种主题string / enumlight
prefixIcon自定义前缀图标string / ComponentClock
clearIcon自定义清除图标string / ComponentCircleClose
start开始时间string09:00
end结束时间string18:00
step间隔时间string00:30
minTime最早时间点,早于该时间的时间段将被禁用string
maxTime最晚时间点,晚于该时间的时间段将被禁用string
format设置时间格式string see formatsHH:mm
emptyValues组件的空值配置 参考config-providerarray
valueOnClear清空选项的值 参考 config-providerstring / number / boolean / Function

Events

事件名说明类型
change用户确认选定的值时触发Function
blur在组件 Input 失去焦点时触发Function
focus在组件 Input 获得焦点时触发Function
clear可清空的单选模式下用户点击清空按钮时触发Function

FormCreate 是一个开源项目,基于 MIT 许可证发布,欢迎个人和企业用户免费使用