EDatePicker 日期选择
示例与代码
日期选择
格式输入与双面板范围
日期选择
属性
accessibleNamestring辅助技术读取的名称;建议为无文字控件设置可读名称。
placeholderTextappendComponentComponent自定义输入附加区或列表尾部的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
nullautomaticDropdownbool输入框获得焦点时自动展开日期面板。
falsecellComponentComponent自定义表格单元格或日期格的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
nullclearIconint组件使用的图标。
EIcons.*
0(无图标)
EIcons.CIRCLE_XMARKclearablebool显示清除操作;评分中允许再次点击当前分数清零。
truedefaultTimevar日期时间选择的默认时刻,可为 Date 或范围起止时间数组。
nulldefaultValuevar未选中值时的默认面板定位值。
nulldisabledDatevar日期禁用函数,接收 JavaScript Date 并返回是否禁用。
nullechoModeenum输入内容的显示模式。
TextInput.NormalTextInput.PasswordTextInput.NoEchoTextInput.PasswordEchoOnEdit
动态绑定emptyValuesvar判定为空值的数组;默认包含 undefined、null 和空字符串。
继承 Provider,默认 [undefined, null, ""]enabledbool是否允许交互;false 时控件禁用。
trueendPlaceholderstring空值时显示的占位文字。
""fallbackPlacementsvar首选位置空间不足时尝试的位置数组。
placement 可选值组成的数组
["top-start", "bottom-start"]fontfont字体配置,控制字体、字号及文字样式。
常用字段:
family、pixelSize、pointSize
bold、italic、weight
underline、strikeout
letterSpacing、wordSpacing
应用字体formatstring显示格式;日期时间使用格式串,进度可使用函数,倒计时使用时间占位符。
""formattervar格式化回调,把当前值转换为显示文字。
nullheightreal组件尺寸,单位为像素;可绑定父布局尺寸。
implicitHeightmaxDatestring可选日期上下限,格式 yyyy-MM-dd;空字符串不限制。
""maximumLengthint最多允许输入的字符数。
32767minDatestring可选日期上下限,格式 yyyy-MM-dd;空字符串不限制。
""nextMonthIconint组件使用的图标。
EIcons.*
0(无图标)
EIcons.CHEVRON_RIGHTnextYearIconint组件使用的图标。
EIcons.*
0(无图标)
EIcons.CHEVRONS_RIGHTparservar输入解析函数,把显示文字转换为底层值。
nullpasswordVisiblebool密码是否以明文显示。
falseplaceholderTextstring空值时显示的占位文字。
随当前语言变化placementstring选择面板相对于输入框的位置。
"top" / "top-start""top-end" / "bottom""bottom-start" / "bottom-end""left" / "left-start""left-end" / "right""right-start" / "right-end"
"bottom-start"prefixComponentComponent自定义前缀的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
nullprefixIconint组件使用的图标。
EIcons.*
0(无图标)
EIcons.CALENDARprependComponentComponent自定义输入前置区的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
nullprevMonthIconint组件使用的图标。
EIcons.*
0(无图标)
EIcons.CHEVRON_LEFTprevYearIconint组件使用的图标。
EIcons.*
0(无图标)
EIcons.CHEVRONS_LEFTrangeSeparatorstring起止值之间的分隔文字。
" — "readOnlybool禁止用户编辑或评分,仍可通过属性设置值。
trueshortcutsvar日期快捷选项的数据数组。
字段:
text, value
[]showConfirmbool是否显示确认按钮。
trueshowPasswordbool启用密码输入及密码显示切换。
falseshowWeekNumberbool显示周序号。
falseshowWordLimitbool显示当前字数与长度上限。
falsesinglePanelbool范围选择只显示一个日期面板。
falsesizeint控件尺寸;默认继承最近的 EConfigProvider。
EStyle.SmallEStyle.MediumEStyle.Large
继承 Provider,默认 EStyle.MediumstartPlaceholderstring空值时显示的占位文字。
""styleTypeint语义配色风格。
EStyle.DefaultEStyle.PrimaryEStyle.SuccessEStyle.InfoEStyle.WarningEStyle.Danger
EStyle.PrimarysuffixComponentComponent自定义后缀的 Component 插槽;null 使用默认内容。 委托上下文见本页示例。
nullsuffixIconint组件使用的图标。
EIcons.*
0(无图标)
0textstring显示的文字内容。
展开默认值
Array.isArray(value) ? value.map(displayValue).join(isRange ? rangeSeparator : ", ") : displayValue(value)textColorcolor文字颜色。
动态绑定typestring日期的选择单位以及单选、多选或范围模式。
"date" / "dates""week" / "month""months" / "year""years" / "quarter""quarters" / "daterange""monthrange" / "yearrange""quarterrange"
"date"unlinkPanelsbool范围选择的两个日期面板独立翻页。
falsevalidateEventbool值变化时是否向所属表单派发校验请求。
truevalidationMessagestring校验结果说明或外部错误文字。
""validationStateint输入校验状态。
EValidationState.NoneEValidationState.SuccessEValidationState.WarningEValidationState.Error
EValidationState.Nonevaluevar当前值;通过属性绑定读写,数组形式用于多选或范围选择。
""valueFormatstring对外 value 的日期时间格式;为空时使用组件默认格式。
""valueOnClearvar清除后的值,也可传函数返回清除值;默认继承配置。
继承 Provider,默认 undefinedvisiblebool是否显示组件。
truewidthreal组件尺寸,单位为像素;可绑定父布局尺寸。
implicitWidthcalendarLocalevar只读日期时间解析、格式化和面板使用的语言配置。
由运行时计算canonicalFormatstring只读用于解析和序列化 value 的实际日期时间格式。
由运行时计算displayFormatstring只读解析后的日期时间显示格式。
由运行时计算endPanelvar只读日期选择的起始或结束面板对象。
由运行时计算hasValidationErrorbool只读当前校验状态是否为 Error。
由运行时计算isRangebool只读启用起止范围选择。
由运行时计算multiplebool只读是否允许多选。
由运行时计算panelvar只读日期选择的起始或结束面板对象。
由运行时计算popupvar只读内部菜单、弹层或提示对象引用。
由运行时计算wordCountint只读当前输入字符数量。
由运行时计算showPasswordStrengthbool聚焦密码输入时显示强度与规则检查。
falsepasswordRulesvar密码规则数组;每项包含 label 及 minLength 或 pattern。
展开默认值
[ {label: ELocale.texts.PasswordLength, minLength: 8}, {label: ELocale.texts.PasswordUppercase, pattern: /[A-Z]/}, {label: ELocale.texts.PasswordLowercase, pattern: /[a-z]/}, {label: ELocale.texts.PasswordNumber, pattern: /[0-9]/}, {label: ELocale.texts.PasswordSymbol, pattern: /[^A-Za-z0-9]/} ]passwordStrengthreal只读通过规则的比例,范围为 0 到 1。
展开默认值
passwordRequirements.length ? passwordRequirements.filter(function(rule) { return rule.passed }).length / passwordRequirements.length : 0passwordRequirementsvar只读包含 label 与 passed 的规则检查结果。
展开默认值
Array.isArray(passwordRules) ? passwordRules.map(function(rule) { let passed = false try { if (rule && rule.minLength !== undefined) passed = text.length >= Number(rule.minLength) else if (rule && rule.pattern) { const expression = new RegExp(rule.pattern) passed = expression.test(text) } } catch (error) { passed = false } return {label: rule && rule.label ? String(rule.label) : "", passed: passed} }) : []信号
picked(var value)选定值后触发,value 为选中的值。
changed(var value)所选值变化时触发,value 为新的值。
calendarChanged(var value)选择过程中的日历值变化时触发,value 为当前选择值。
inputRejected(string text)输入无法转换为有效值时触发,text 为被拒绝的输入文字。
popupVisibleChanged(bool visible)选择面板显示或隐藏时触发,visible 表示面板是否可见。
viewChanged(var date, string mode)日历显示的日期或视图模式变化时触发,date 为显示日期,mode 为视图模式。
方法
close()关闭组件的面板或弹窗。
clearValue()清空当前日期选择。
commitInput(input)提交输入文字;内容无效时保留原值并发出 inputRejected。
commitDate(input)提交给定日期作为当前选择。
open()打开组件的面板或弹窗。