import{ax as o,al as n,z as l,A as h,B as d,R as s,b2 as r,O as e,J as i}from"./chunks/framework.DkLJC2NO.js";const y=JSON.parse('{"title":"DatePicker 日期选择器","description":"","frontmatter":{},"headers":[],"relativePath":"form-config/fields/date-picker.md","filePath":"form-config/fields/date-picker.md"}'),p={name:"form-config/fields/date-picker.md"};function c(k,t,m,g,b,f){const a=n("demo-block");return h(),l("div",null,[t[4]||(t[4]=d("h1",{id:"datepicker-日期选择器",tabindex:"-1"},[e("DatePicker 日期选择器 "),d("a",{class:"header-anchor",href:"#datepicker-日期选择器","aria-label":'Permalink to "DatePicker 日期选择器"'},"")],-1)),t[5]||(t[5]=d("p",null,"用于选择或输入日期",-1)),t[6]||(t[6]=d("h2",{id:"基础用法",tabindex:"-1"},[e("基础用法 "),d("a",{class:"header-anchor",href:"#基础用法","aria-label":'Permalink to "基础用法"'},"")],-1)),s(a,{type:"form",config:[{type:"date",name:"date",text:"日期选择器"}]},{source:i(()=>[...t[0]||(t[0]=[d("p",null," 以日期为基本单位,基础的日期选择控件 ",-1)])]),_:1}),t[7]||(t[7]=d("h2",{id:"禁用状态",tabindex:"-1"},[e("禁用状态 "),d("a",{class:"header-anchor",href:"#禁用状态","aria-label":'Permalink to "禁用状态"'},"")],-1)),s(a,{type:"form",config:[{type:"date",name:"date",text:"日期选择器",disabled:()=>!0}]},{source:i(()=>[...t[1]||(t[1]=[d("p",null,[e(" 通过 "),d("code",null,"disabled"),e(" 属性禁用日期选择器 ")],-1)])]),_:1}),t[8]||(t[8]=d("h2",{id:"占位符",tabindex:"-1"},[e("占位符 "),d("a",{class:"header-anchor",href:"#占位符","aria-label":'Permalink to "占位符"'},"")],-1)),s(a,{type:"form",config:[{type:"date",name:"date",text:"日期选择器",placeholder:"请选择日期"}]},{source:i(()=>[...t[2]||(t[2]=[d("p",null,[e(" 通过 "),d("code",null,"placeholder"),e(" 属性设置输入框占位文本 ")],-1)])]),_:1}),t[9]||(t[9]=r('
使用format指定输入框的格式;使用valueFormat指定绑定值的格式。
默认情况下,组件的 format 默认值为 YYYY/MM/DD,valueFormat 默认值为 YYYY/MM/DD。以下为可用的格式化字串,以 UTC 2017年1月2日 03:04:05 为例:
WARNING
请注意大小写
| 格式 | 含义 | 备注 | 举例 |
|---|---|---|---|
YYYY | 年 | 2017 | |
M | 月 | 不补0 | 1 |
MM | 月 | 01 | |
D | 日 | 不补0 | 2 |
DD | 日 | 02 | |
H | 小时 | 24小时制;不补0 | 3 |
HH | 小时 | 24小时制 | 03 |
h | 小时 | 12小时制,须和 A 或 a 使用;不补0 | 3 |
hh | 小时 | 12小时制,须和 A 或 a 使用 | 03 |
m | 分钟 | 不补0 | 4 |
mm | 分钟 | 04 | |
s | 秒 | 不补0 | 5 |
ss | 秒 | 05 | |
x | JS时间戳 | 组件绑定值为number类型 | 1483326245000 |
[MM] | 不需要格式化字符 | 使用方括号标识不需要格式化的字符 (如 [A] [MM]) | MM |
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|---|---|---|---|---|
| name | 绑定值的字段名 | string | — | — |
| text | 表单标签 | string | — | — |
| placeholder | 输入框占位文本 | string | — | — |
| disabled | 是否禁用 | boolean / FilterFunction | — | false |
| format | 显示在输入框中的格式 | string | 见日期格式 | YYYY/MM/DD |
| valueFormat | 绑定值的格式。不指定则绑定值为 Date 对象 | string | 见日期格式 | YYYY/MM/DD |
| onChange | 值变化时触发的函数 | OnChangeHandler | — | — |
interface DateConfig extends FormItem, Input {
type: 'date';
format?: 'YYYY-MM-dd HH:mm:ss' | string;
valueFormat?: 'YYYY-MM-dd HH:mm:ss' | string;
}