1.1.2 • Published 1 year ago

@pqcqcqc/qc-components v1.1.2

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

QC-Components

一款基于AntdV的 高效开发组件库

更多文档待完善..........

组件结构

  • 重要,这是下面配置的基础

  • npm.io

  • 红色部分:

    • 表单Form组件
  • 绿色部分:

    • 表单标题
    • 按钮或自定义按钮
  • 黄色部分:

    • 表单项Form.Item组件
  • 蓝色部分:

    • 真实输入框或者内容展示Component组件

Schema

一个表单的所有配置,称为Schema。

Schema的不同对应了不同的表单内容。

  • 类型信息
    • title(可选)表单的标题,显示在表单组件的最上方。

    • items:(必须) 表单内的组件,比如输入框等,下面有详细说明。

    • onSubmit:(可选)表单提交事件。

      • 入参:表单的输入结果对象(响应式)
      • 返回值:void

    • onReset:(可选)表单点击重置事件。

      • 入参:无
      • 返回值:void
    • formProps:表单整体属性

      • 常用属性:

        • labelCol
        • wrapperCol
      • 其他属性:

        • Form #

          PropertyDescriptionTypeDefault ValueVersion
          colonchange default props colon value of Form.Item (only effective when prop layout is horizontal)booleantrue
          disabledSet form component disable, only available for antdv componentsbooleanfalse4.0
          hideRequiredMarkHide required mark of all form itemsBooleanfalse
          labelAligntext align of label of all items'left' | 'right''right'
          labelColThe layout of label. You can set span offset to something like {span: 3, offset: 12} or sm: {span: 3, offset: 12} same as with <Col>object
          labelWrapwhether label can be wrapbooleanfalse3.0
          layoutDefine form layout'horizontal'|'vertical'|'inline''horizontal'
          modeldata of form componentobject
          nameForm name. Will be the prefix of Field idstring-2.0.0
          noStyleNo style for true, used as a pure field controlbooleanfalse3.0
          rulesvalidation rules of formobject
          scrollToFirstErrorAuto scroll to first failed field when submitboolean | optionsfalse2.0.0
          validateOnRuleChangewhether to trigger validation when the rules prop is changedbooleantrue
          validateTriggerConfig field validate triggerstring | string[]change2.0.0
          wrapperColThe layout for input controls, same as labelColobject
    • formEvent:表单事件

      • Methods #

        MethodDescriptionParametersVersion
        clearValidateclear validation message for certain fields. The parameter is name or an array of names of the form items whose validation messages will be removed. When omitted, all fields' validation messages will be cleared(nameList?: NamePath[]) => void
        resetFieldsreset all the fields and remove validation result(nameList?: NamePath[]) => void
        scrollToFieldScroll to field position(name: NamePath, options: [ScrollOptions]) => void
        validateValidate fields, it is same as validateFields(nameList?: NamePath[]) => Promise
        validateFieldsValidate fields(nameList?: NamePath[]) => Promise
    • className:Form组件的类名

    • customBtns:自定义按钮

      • npm.io

      • 红色部分

        • 自定义按钮最外层div
      • 黄色部分:

        • 按钮外围div
      • 绿色部分:

        • 按钮主体
      • 自定义按钮的类型信息:

        • text:按钮文本(同时作为黄色部分div的key,尽量不要重复)
        • onClick:点击事件

          • 入参:
            • model:表单的数据
            • event?可选:点击事件
          • 返回值:
            • void
        • props:按钮参数

          • Different button styles can be generated by setting Button properties. The recommended order is: type -> shape -> size -> loading -> disabled.

            PropertyDescriptionTypeDefaultVersion
            blockoption to fit button width to its parent widthbooleanfalse
            dangerset the danger status of buttonbooleanfalse2.2.0
            disableddisabled state of buttonbooleanfalse
            ghostmake background transparent and invert text and border colorsbooleanfalse
            hrefredirect url of link buttonstring-
            htmlTypeset the original html type of button, see: MDNstringbutton
            iconset the icon of button, see: Icon componentv-slot-
            loadingset the loading status of buttonboolean | { delay: number }false
            shapeCan be set button shapedefaultcirclerounddefault
            sizeset the size of buttonlargemiddlesmallmiddle
            targetsame as target attribute of a, works when href is specifiedstring-
            typecan be set button typeprimaryghostdashedlinktextdefaultdefault
        • outterStyle:黄色部分Style参数

        • style:按钮本体上Style参数
    • customBtnsStyle:自定义按钮最外层div样式(红色部分)

  • 表单项参数

  • npm.io

    • label:表单项显示名称

    • field:表单项字段,在表单数据对象中的字段名

    • component:表单项内组件,支持已经有的内置组件或者自定义组件

    • componentProps:表单项内(蓝色部分)组件的参数,根据不同的component,可以传入不同的参数

    • componentEvent:表单项内(蓝色部分)组件的事件参数,如click:() =>{}

    • formItemProps:表单项(黄色部分)参数

      • Form.Item #

        PropertyDescriptionTypeDefault ValueVersion
        autoLinkWhether to automatically associate form fields. In most cases, you can use automatic association. If the conditions for automatic association are not met, you can manually associate them. See the notes below.booleantrue
        colonUsed with label, whether to display : after label text.booleantrue
        extraThe extra prompt message. It is similar to help. Usage example: to display error message and prompt message at the same time.string|slot
        hasFeedbackUsed with validateStatus, this option specifies the validation status icon. Recommended to be used only with Input.booleanfalse
        helpThe prompt message. If not provided, the prompt message will be generated by the validation rule.string|slot
        htmlForSet sub label htmlFor.string
        labelLabel textstring|slot
        labelAligntext align of label'left' | 'right''right'
        labelColThe layout of label. You can set span offset to something like {span: 3, offset: 12} or sm: {span: 3, offset: 12} same as with <Col>object
        namea key of model. In the use of validate and resetFields method, the attribute is requiredNamePath2.0.0
        requiredWhether provided or not, it will be generated by the validation rule.booleanfalse
        rulesvalidation rules of formobject | array
        tooltipConfig tooltip infostring | slot4.0.4
        validateFirstWhether stop validate on first rule of error for this field.booleanfalse
        validateStatusThe validation status. If not provided, it will be generated by validation rule. options: 'success' 'warning' 'error' 'validating'string
        validateTriggerWhen to validate the value of children nodestring | string[]change
        wrapperColThe layout for input controls, same as labelColobject
    • value:表单初始化参数,重置时默认将表单组件设置为这个值

    • next:下一级表单

      • 入参:
        • model :当前表单项的输入内容
      • 返回值:DyForm动态表单 | undefined | null
    • nextFormStyle:下一级表单的外围div样式

    • onShow:是否显示这个表单项

      • 入参:
        • modelValue:当前表单的完整输入参数
      • 返回值:
        • boolean:为true时显示该表单项,false时不显示该项

当前支持的组件

export type InnerComponent =
	| "Text"
	| "Password"
	| "Textarea"
	| "Number"
	| "Select"
	| "Radio"
	| "Checkbox"
	| "DatePicker"
	| "Rate"
	| "Slider"
	| "Switch"
	| "Upload"
	| "TreeSelect"
	| "TimePicker"
	| "AutoComplete"
	| "Tag"
	| "Mentions"
	| "Divider"
	| "AvatarGroup"
	| "Corn";

Text组件

<<<<<<< HEAD

======= npm.io

示例
  •   		// input
          		{
          			label: "姓名",
          			field: "name",
          			component: "Text",
          			componentProps: {
          				allowClear: true,
          				showCount: true,
          				maxlength: 20,
          				style: {
          					width: "400px",
          				},
          			},
          			formItemProps: {
          				rules: [
          					{
          						required: true,
          						message: "请输入姓名",
          						trigger: "blur",
          					},
          				],
          				colon: false,
          				tooltip: "在这里输入姓名",
          			},
          			value: "百里守约",
                  // 动态下一级表单
          			next: (model: any): DyForm | undefined => {
          				if (model == "百里守约") {
          					return {
          						items: [
          							{
          								label: "武器",
          								field: "weapon",
          								component: "Text",
          								componentProps: {
          									allowClear: true,
          									showCount: true,
          									maxlength: 80,
          									style: {
          										width: "350px",
          									},
          								},
          								formItemProps: {
          									rules: [
          										{
          											required: true,
          											message: "武器只能是ABCDE中的一个",
          											trigger: "blur",
          											type: "enum",
          											enum: ["A", "B", "C", "D", "E"],
          										},
          									],
          									style: {
          										marginTop: "10px",
          									},
          									labelCol: { span: 3 },
          								},
          							},
          						],
          					};
          				}
          			},
          		},

204bb0431fa9333f31e8136e4e5f80ade0f3f556

​ Input #

PropertyDescriptionTypeDefaultVersion
addonAfterThe label text displayed after (on the right side of) the input field.string|slot
addonBeforeThe label text displayed before (on the left side of) the input field.string|slot
allowClearallow to remove input content with clear iconboolean
borderedWhether has border stylebooleantrue4.5.0
clearIconcustom clear icon when allowClearslot<CloseCircleFilled />3.3.0
defaultValueThe initial input contentstring
disabledWhether the input is disabled.booleanfalse
idThe ID for inputstring
maxlengthmax lengthnumber1.5.0
prefixThe prefix icon for the Input.string|slot
showCountWhether show text countbooleanfalse3.0
statusSet validation status'error' | 'warning'-3.3.0
sizeThe size of the input box. Note: in the context of a form, the middle size is used. Available: large middle smallstring-
suffixThe suffix icon for the Input.string|slot
typeThe type of input, see: MDN(use <a-textarea /> instead of type="textarea")stringtext
value(v-model)The input content valuestring

Input Events #

Events NameDescriptionArguments
changecallback when user inputfunction(e)
pressEnterThe callback function that is triggered when Enter key is pressed.function(e)

When Input is used in a Form.Item context, if the Form.Item has the id and options props defined then value, defaultValue, and id props of Input are automatically set.

Password组件

  • 与Text组件相同,但指定了type一定为password

  • 示例
    •   let qspassword = ""
        
        const commonComponentProps = {
          allowClear: true,
          showCount: true,
          maxlength: 30
        }
        
        const passwordAndConfirmPassword: DyFormItem[] = [
          {
            label: "密码",
            field: "password",
            component: "Password",
            formItemProps: {
              rules: [
                { required: true, message: "请输入密码" },
                {
                  min: 5,
                  max: 30,
                  message: "密码长度为5-30位"
                },
                {
                  validator: (_rule: any, value: any) => {
                    qspassword = value
                    return Promise.resolve()
                  }
                }
              ]
            },
            componentProps: commonComponentProps
          },
          {
            label: "确认密码",
            field: "confirmPassword",
            component: "Password",
            formItemProps: {
              rules: [
                { required: true, message: "请输入确认密码" },
                {
                  min: 5,
                  max: 30,
                  message: "密码长度为5-30位"
                },
                {
                  validator: (_rule: any, value: any) => {
                    if (value !== qspassword) {
                      return Promise.reject("两次输入密码不一致")
                    }
                    return Promise.resolve()
                  }
                }
              ]
            },
            componentProps: commonComponentProps
          }
        ]

Textarea组件

npm.io

示例
  •   {
      			label: "简介",
      			field: "desc",
      			component: "Textarea",
      			componentProps: {
      				allowClear: true,
      				autoSize: {
      					minRows: 4,
      					maxRows: 4,
      				},
      				maxlength: 200,
      				showCount: true,
      			},
      			formItemProps: {
      				rules: [
      					{
      						required: true,
      						message: "请输入简介",
      						trigger: "blur",
      					},
      				],
      			},
      		},

TextArea #

PropertyDescriptionTypeDefaultVersion
allowClearallow to remove input content with clear iconboolean1.5.0
autosizeHeight autosize feature, can be set to true | falseor an object{ minRows: 2, maxRows: 6 }boolean|objectfalse
defaultValueThe initial input contentstring
showCountWhether show text countbooleanfalse
value(v-model)The input content valuestring

TextArea Events #

Events NameDescriptionArguments
pressEnterThe callback function that is triggered when Enter key is pressed.function(e)

Number组件

npm.io

示例
  •   // number 
      		{
      			label: "年龄",
      			field: "age",
      			component: "Number",
      			componentProps: {
      				allowClear: true,
      				style: {
      					width: "400px",
      				},
      			},
      			formItemProps: {
      				rules: [
      					{
      						required: true,
      						message: "请输入年龄",
      						trigger: "blur",
      					},
      				],
      			},
      		},

API#

#

propertydescriptiontypedefault
addonAfterThe label text displayed after (on the right side of) the input fieldslot-3.0
addonBeforeThe label text displayed before (on the left side of) the input fieldslot-3.0
autofocusget focus when component mountedbooleanfalse
borderedWhether has border stylebooleantrue3.0
controlsWhether to show +- controlsbooleantrue3.0
decimalSeparatordecimal separatorstring-
defaultValueinitial valuenumber
disableddisable the inputbooleanfalse
formatterSpecifies the format of the value presentedfunction(value: number | string, info: { userTyping: boolean, input: string }): string-info: 3.0
keyboardIf enable keyboard behaviorbooleantrue3.0
maxmax valuenumberInfinity
minmin valuenumber-Infinity
parserSpecifies the value extracted from formatterfunction( string): number-
precisionprecision of input valuenumber-
prefixThe prefix icon for the Inputslot-3.0
sizeheight of input boxstring-
statusSet validation status'error' | 'warning'-3.3.0
stepThe number to which the current value is increased or decreased. It can be an integer or decimal.number|string1
stringModeSet value as string to support high precision decimals. Will return string value by changebooleanfalse3.0
value(v-model)current valuenumber
upIconcustom up iconslot<UpOutlined />3.3.0
downIconcustom up downslot<DownOutlined />3.3.0

events #

Events NameDescriptionArgumentsVersion
changeThe callback triggered when the value is changed.function(value: number | string)
pressEnterThe callback function that is triggered when Enter key is pressed.function(e)1.5.0
stepThe callback function that is triggered when click up or down buttons(value: number, info: { offset: number, type: 'up' | 'down' }) => void3.0

Select

npm.io

  • 注意,下面的文档来自Antd,在本项目中,options可以传入一个异步函数,返回值为选项列表,在组件加载时将会自动调用该函数获取参数

  • 示例
    •   		// select
            		{
            			label: "固定国家选择",
            			field: "country",
            			component: "Select",
            			componentProps: {
            				allowClear: true,
            				options: [
            					{ value: "中国", label: "中国" },
            					{ value: "美国", label: "美国" },
            					{ value: "日本", label: "日本" },
            					{ value: "韩国", label: "韩国" },
            				],
            			},
            		},
            		// async select 
            		{
            			label: "异步国家选择",
            			field: "async-country",
            			component: "Select",
            			componentProps: {
            				allowClear: true,
            				options: () => {
            					return new Promise<Options>((resolve) => {
            						setTimeout(() => {
            							resolve([
            								{ value: "中国", label: "中国" },
            								{ value: "美国", label: "美国" },
            								{ value: "日本", label: "日本" },
            								{ value: "韩国", label: "韩国" },
            							]);
            						}, 1000);
            					});
            				},
            			},
            		},

Select props #

PropertyDescriptionTypeDefaultVersion
allowClearShow clear button.booleanfalse
autoClearSearchValueWhether the current search will be cleared on selecting an item. Only applies when mode is set to multiple or tags.booleantrue
autofocusGet focus by defaultbooleanfalse
borderedWhether has border stylebooleantrue
clearIconThe custom clear iconVNode | slot-
defaultActiveFirstOptionWhether active first option by defaultbooleantrue
defaultOpenInitial open state of dropdownboolean-
disabledWhether disabled selectbooleanfalse
popupClassNameclassName of dropdown menustring-4.0
dropdownMatchSelectWidthDetermine whether the dropdown menu and the select input are the same width. Default set min-width same as input. Will ignore when value less than select width. false will disable virtual scrollboolean | numbertrue
dropdownMenuStyleadditional style applied to dropdown menuobject-
dropdownRenderCustomize dropdown content({menuNode: VNode, props}) => VNode | v-slot-
dropdownStylestyle of dropdown menuobject-
fieldNamesCustomize node label, value, options field nameobject{ label: label, value: value, options: options }3.0
filterOptionIf true, filter options by input, if function, filter options against it. The function will receive two arguments, inputValue and option, if the function returns true, the option will be included in the filtered set; Otherwise, it will be excluded.booleanfunction(inputValue, option)true
filterSortSort function for search options sorting, see Array.sort's compareFunction(optionA: Option, optionB: Option) => number-3.0
firstActiveValueValue of action option by defaultstring | string[]-
getPopupContainerParent Node which the selector should be rendered to. Default to body. When position issues happen, try to modify it into scrollable content and position it relative.function(triggerNode)() => document.body
labelInValuewhether to embed label in value, turn the format of value from string to {key: string, label: vNodes, originLabel: any}, originLabel (3.1) maintains the original type. If the node is constructed through a-select-option children, the value is a function (the default slot of a-select-option)booleanfalse
listHeightConfig popup heightnumber256
loadingindicate loading statebooleanfalse
maxTagCountMax tag count to shownumber-
maxTagPlaceholderPlaceholder for not showing tagsslot | function(omittedValues)-
maxTagTextLengthMax text length to shownumber-
menuItemSelectedIconThe custom menuItemSelected iconVNode | slot-
modeSet mode of Select'multiple' | 'tags'-
notFoundContentSpecify content to show when no result matches..string|slotNot Found
openControlled open state of dropdownboolean-
optioncustom render option by slotv-slot:option="{value, label, disabled, key, title}"-2.2.5
optionFilterPropWhich prop value of option will be used for filter if filterOption is truestringvalue
optionLabelPropWhich prop value of option will render as content of select.stringchildrenlabel(when use options)
optionsData of the selectOption, manual construction work is no longer needed if this property has been setArray<{value, label, disabled, key, title}>[]
placeholderPlaceholder of selectstring|slot-
placementThe position where the selection box pops upbottomLeft bottomRight topLeft topRightbottomLeft3.3.0
removeIconThe custom remove iconVNode | slot-
searchValueThe current input "search" textstring-
showArrowWhether to show the drop-down arrowbooleansingle:true, multiple:false
showSearchWhether select is searchablebooleansingle:false, multiple:true
sizeSize of Select input. default large smallstringdefault
statusSet validation status'error' | 'warning'-3.3.0
suffixIconThe custom suffix iconVNode | slot-
tagRenderCustomize tag render, only applies when mode is set to multiple or tagsslot | (props) => any-
tokenSeparatorsSeparator used to tokenize, only applies when mode="tags"string[]-
value(v-model)Current selected option.string|number|string[]|number[]-
virtualDisable virtual scroll when set to falsebooleantrue3.0

Note, if you find that the drop-down menu scrolls with the page, or you need to trigger Select in other popup layers, please try to use getPopupContainer={triggerNode => triggerNode.parentElement} to fix the drop-down popup rendering node in the parent element of the trigger .

events #

Events NameDescriptionArguments
blurCalled when blurfunction
changeCalled when select an option or input value change, or value of input is changed in combobox modefunction(value, option:Option | Array)
deselectCalled when a option is deselected, the params are option's value (or key) . only called for multiple or tags, effective in multiple or tags mode only.function(value, option:Option)
dropdownVisibleChangeCall when dropdown openfunction(open)
focusCalled when focusfunction
inputKeyDownCalled when key pressedfunction
mouseenterCalled when mouse enterfunction
mouseleaveCalled when mouse leavefunction
popupScrollCalled when dropdown scrollsfunction
searchCallback function that is fired when input changed.function(value: string)
selectCalled when a option is selected, the params are option's value (or key) and option instance.function(value, option:Option)

Radio

npm.io

npm.io

  • 当使用异步加载,出现错误时可以点击重试。
  • 与Select相似,参考antd文档,同样支持options传入异步函数获取列表

  • 示例

    •   		// radio
            		{
            			label: "性别",
            			field: "sex",
            			component: "Radio",
            			componentProps: {
            				options: [
            					{ value: 1, label: "男" },
            					{ value: 2, label: "女" },
            					{ value: 3, label: "保密" },
            				],
            			},
            			formItemProps: {
            				rules: [
            					{
            						required: true,
            						message: "请选择性别",
            						trigger: "blur",
            					},
            				],
            				hidden: false,
            			},
            			value: 1,
            		},
            		// async radio
            		{
            			label: "异步选择",
            			field: "async-test",
            			component: "Radio",
            			componentProps: {
            				options: async () => await getOptionApi(),
            			},
            			formItemProps: {
            				rules: [
            					{
            						required: true,
            						message: "请选择性别",
            						trigger: "blur",
            					},
            				],
            			},
            			value: 1,
            		},

CheckBox

npm.io

npm.io

  • 同上,类似Radio
示例
  •   		// checkbox
          		{
          			label: "兴趣",
          			field: "hobby",
          			component: "Checkbox",
          			componentProps: {
          				options: [
          					{ value: 1, label: "足球" },
          					{ value: 2, label: "篮球" },
          					{ value: 3, label: "排球" },
          				],
          			},
          		},
          		// async checkbox
          		{
          			label: "异步多选",
          			field: "async-checkbox",
          			component: "Checkbox",
          			componentProps: {
          				options: async () => await getOptionApi(),
          			},
          		},

DatePicker

npm.io

npm.io

示例
  •   		// datepicker
          		{
          			label: "生日",
          			field: "birthday",
          			component: "DatePicker",
          			formItemProps: {
          				rules: [
          					{
          						required: true,
          						message: "生日日期不能为空",
          						trigger: "blur",
          					},
          				],
          			},
          			componentProps: {
          				format: "YYYY-MM-DD",
          				valueFormat: "YYYY-MM-DD",
          			},
          		},
  •    let timeSelectStart: Dayjs = dayjs()
       ......
       	// 开始时间(在当前时间之后)
           {
             label: "开始时间",
             field: "startTime",
             component: "DatePicker",
             //格式:2024-05-14 08:30:22
             formItemProps: {
               rules: [
                 { required: true, message: "请选择开始时间" },
                 // 建立一个规则用来缓存已经选择的时间
                 {
                   validator: (_rule: any, value: any) => {
                     timeSelectStart = value
                     return Promise.resolve()
                   }
                 }
               ]
             },
             componentProps: {
               disabledDate: (current: Dayjs) => {
                 return current && current < dayjs()
               },
               disabledTime: (current: Dayjs) => {
                 if (current.isSame(dayjs(), "day")) {
                   return {
                     disabledHours: () => {
                       return [...Array(24).keys()].filter((hour) => hour < dayjs().hour())
                     }
                   }
                 }
                 return {}
               },
               ...componentStyle,
               format: "YYYY-MM-DD HH:mm:ss",
               valueFormat: "YYYY-MM-DD HH:mm:ss",
               showTime: true,
               placeholder: "请选择开始时间"
             }
           },
           // 结束时间,在开始时间之后
           {
             label: "结束时间",
             field: "endTime",
             component: "DatePicker",
             formItemProps: {
               rules: [
                 { required: true, message: "请选择结束时间" },
                 {
                   validator: (_rule: any, value: any) => {
                     if (value < timeSelectStart) {
                       return Promise.reject("结束时间不能早于开始时间")
                     }
                     return Promise.resolve()
                   }
                 }
               ]
             },
             componentProps: {
               disabledDate: (current: Dayjs) => {
                 return current && current < timeSelectStart
               },
               disabledTime: (current: Dayjs) => {
                 if (current.isSame(timeSelectStart, "day")) {
                   return {
                     disabledHours: () => {
                       return [...Array(24).keys()].filter((hour) => hour < timeSelectStart.hour())
                     }
                   }
                 }
                 return {}
               },
               ...componentStyle,
               format: "YYYY-MM-DD HH:mm:ss",
               valueFormat: "YYYY-MM-DD HH:mm:ss",
               showTime: true,
               placeholder: "请选择结束时间"
             }
           },

Common API #

The following APIs are shared by DatePicker, RangePicker.

PropertyDescriptionTypeDefaultVersion
allowClearWhether to show clear buttonbooleantrue
autofocusIf get focus when component mountedbooleanfalse
borderedWhether has border stylebooleantrue
dateRenderCustom rendering function for date cellsv-slot:dateRender="{current, today}"-
disabledDetermine whether the DatePicker is disabledbooleanfalse
disabledDateSpecify the date that cannot be selected(currentDate: dayjs) => boolean-
formatTo set the date format, refer to dayjs. When an array is provided, all values are used for parsing and first value is used for formatting, support Custom FormatformatTypeYYYY-MM-DD
dropdownClassNameTo customize the className of the popup calendarstring-
getPopupContainerTo set the container of the floating layer, while the default is to create a div element in bodyfunction(trigger)-
inputReadOnlySet the readonly attribute of the input tag (avoids virtual keyboard on touch devices)booleanfalse
localeLocalization configurationobjectdefault
modeThe picker panel modetimedatemonthyeardecade-
nextIconThe custom next iconslot-3.0
openThe open state of pickerboolean-
pickerSet picker typedateweekmonthquarteryeardatequarter
placeholderThe placeholder of date inputstring | string,string-
placementThe position where the selection box pops upbottomLeft bottomRight topLeft topRightbottomLeft3.3.0
popupStyleTo customize the style of the popup calendarCSSProperties{}
presetsThe preset ranges for quick selection{ label: slot, value: dayjs }[]-4.0
prevIconThe custom prev iconslot-3.0
sizeTo determine the size of the input box, the height of large and small, are 40px and 24px respectively, while default size is 32pxlargemiddlesmall-
statusSet validation status'error' | 'warning'-3.3.0
suffixIconThe custom suffix iconv-slot:suffixIcon-
superNextIconThe custom super next iconslot-3.0
superPrevIconThe custom super prev iconslot-3.0
valueFormatoptional, format of binding value. If not specified, the binding value will be a Date objectstring, date formats-

Common Events #

Events NameDescriptionArgumentsVersion
openChangea callback function, can be executed whether the popup calendar is popped up or closedfunction(status)
panelChangecallback when picker panel mode is changedfunction(value, mode)

Common Methods #

NameDescriptionVersion
blur()remove focus
focus()get focus

DatePicker #

PropertyDescriptionTypeDefaultVersion
defaultPickerValueTo set default picker datedayjs-
disabledTimeTo specify the time that cannot be selectedfunction(date)-
formatTo set the date format, refer to dayjsformatTypeYYYY-MM-DD
renderExtraFooterRender extra footer in panelv-slot:renderExtraFooter="mode"-
showNowWhether to show 'Now' button on panel when showTime is setboolean-
showTimeTo provide an additional time selectionobject | booleanTimePicker Options
showTime.defaultValueTo set default time of selected date, demodayjsdayjs()
showTodayWhether to show Today buttonbooleantrue
value(v-model)To set datedayjs-

DatePicker Events #

Events NameDescriptionArgumentsVersion
changea callback function, can be executed when the selected time is changingfunction(date: dayjs | string, dateString: string)
okcallback when click ok buttonfunction(date: dayjs | string)

DatePickerpicker=year(https://www.antdv.com/components/date-picker#datepicker-picker-year)

PropertyDescriptionTypeDefaultVersion
formatTo set the date format, refer to dayjsformatTypeYYYY

DatePickerpicker=quarter(https://www.antdv.com/components/date-picker#datepicker-picker-quarter)

PropertyDescriptionTypeDefaultVersion
formatTo set the date format, refer to dayjsformatTypeYYYY-\QQ

DatePickerpicker=month(https://www.antdv.com/components/date-picker#datepicker-picker-month)

PropertyDescriptionTypeDefaultVersion
formatTo set the date format, refer to dayjsformatTypeYYYY-MM
monthCellRenderCustom month cell content render methodv-slot:monthCellRender="{current, locale}"-

DatePickerpicker=week(https://www.antdv.com/components/date-picker#datepicker-picker-week)

PropertyDescriptionTypeDefaultVersion
formatTo set the date format, refer to dayjsformatTypeYYYY-wo

RangePicker #

PropertyDescriptionTypeDefaultVersion
allowEmptyAllow start or end input leave emptyboolean, booleanfalse, false
dateRenderCustomize date cell.v-slot:dateRender="{current: dayjs, today: dayjs, info: { range: startend }}"-
defaultPickerValueTo set default picker date[dayjs, dayjs]-
disabledIf disable start or endboolean, boolean-
disabledTimeTo specify the time that cannot be selectedfunction(date: dayjs, partial: startend)-
formatTo set the date format, refer to dayjsformatTypeYYYY-MM-DD HH:mm:ss
presetsThe preset ranges for quick selection{ label: slot, value: dayjs
1.1.1

1 year ago

1.0.2

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.2.24

1 year ago

1.0.5

1 year ago

0.2.22

1 year ago

1.0.4

1 year ago

1.1.2

1 year ago

1.0.3

1 year ago

0.2.20

1 year ago

0.2.18

1 year ago

0.2.17

1 year ago

0.2.15

1 year ago

0.2.14

1 year ago

0.2.13

1 year ago

0.2.12

1 year ago

0.2.11

1 year ago

0.2.10

1 year ago

0.2.9

1 year ago

0.2.8

1 year ago

0.2.6

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.1

1 year ago