Skip to content

DatePicker 日期选择器

规则

基础示例(日期)

Props 配置示例

按粒度:周 / 月 / 季度 / 年

js
// 周
const week = {
    type: "datePicker",
    title: "周",
    field: "section_day2",
    value: "2026-20th",
    props: { picker: "week" },
}


// 月
const month = {
    type: "datePicker",
    title: "月",
    field: "section_day3",
    value: "2020-04",
    props: { picker: "month" },
}


// 季度(4.1.0+)
const quarter = {
    type: "datePicker",
    title: "季度",
    field: "section_day4",
    value: "2020-q4",
    props: { picker: "quarter" },
}


// 年
const year = {
    type: "datePicker",
    title: "年",
    field: "section_day5",
    value: "2020",
    props: { picker: "year" },
}

日期区间(RangePicker)

日期时间区间

多选日期(不支持 showTime)

整段禁用

尺寸对比(小 / 中 / 大)

Events 事件示例

参考:Antdv Next DatePicker

valuestring | string[]


DatePicker(默认 picker=date)

参数说明类型默认值版本
defaultPickerValue默认面板日期dayjs--
defaultValue默认日期dayjs--
disabledTime不可选择的时间function(date)--
format展示格式formatTypeYYYY-MM-DD-
multiple多选(不支持 showTime)booleanfalse-
pickerValue受控面板日期dayjs--
renderExtraFooter面板额外页脚(mode) => VueNode--
showNow显示「此刻」boolean--
showTime时间选择Object | booleanTimePicker Options-
showWeek展示当前周booleanfalse-
value日期,支持 v-model:valuedayjs--

DatePicker[picker=year]

参数说明类型默认值
defaultValue默认日期dayjs-
format展示格式formatTypeYYYY
multiple多选booleanfalse
renderExtraFooter页脚() => VueNode-
value日期dayjs-

DatePicker[picker=quarter](4.1.0+)

参数说明类型默认值
defaultValue默认日期dayjs-
format展示格式formatTypeYYYY-\QQ
multiple多选booleanfalse
renderExtraFooter页脚() => VueNode-
value日期dayjs-

DatePicker[picker=month]

参数说明类型默认值
defaultValue默认日期dayjs-
format展示格式formatTypeYYYY-MM
multiple多选booleanfalse
renderExtraFooter页脚() => VueNode-
value日期dayjs-

DatePicker[picker=week]

参数说明类型默认值
defaultValue默认日期dayjs-
format展示格式formatTypeYYYY-wo
multiple多选booleanfalse
renderExtraFooter页脚(mode) => VueNode-
value日期dayjs-
showWeek展示当前周booleantrue

RangePicker

参数说明类型默认值版本
allowEmpty允许起止为空[boolean, boolean][false, false]-
cellRender自定义单元格(current, info) => VueNode--
dateRender已废弃,请用 cellRenderfunction--
defaultPickerValue默认面板日期dayjs[]--
defaultValue默认日期dayjs[]--
disabled禁用起止项[boolean, boolean]--
disabledTime不可选时间function(date, partial, info)--
format展示格式formatTypeYYYY-MM-DD HH:mm:ss-
id输入框 id--
pickerValue受控面板日期dayjs[]--
presets快捷预设{ label: VueNode, value: (Dayjs | (() => Dayjs))[] }[]--
renderExtraFooter页脚() => VueNode--
separator分隔符VueNodeSwapRightOutlined-
showTime时间选择Object | booleanTimePicker Options-
value日期区间dayjs[]--

Events(DatePicker / RangePicker)

事件说明类型版本
change值变化(date: Dayjs | Dayjs[] | null, dateString: string | string[] | null) => void-
update:value同步值(date: Dayjs | Dayjs[] | null) => void-
calendarChange待选区间变化(info.range)(dates, dateStrings, info) => void-
panelChange面板切换(value: Dayjs, mode: PickerMode) => void-
openChange弹层开关(open: boolean) => void-
ok确定() => void-
select选择日期(date: Dayjs) => void-
focus聚焦(event: FocusEvent, info: { range: 'start' | 'end' }) => void-
blur失焦(event: FocusEvent, info: { range: 'start' | 'end' }) => void-
keydown按键(event: KeyboardEvent, preventDefault: VoidFunction) => void-

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