For vue2 projects, use @94ai/common-ui
LLMs.md

nf-form ​

An Element Plus Form wrapper preserving validation and field APIs with expandable query fields.

Import the components below; see the package README for standalone installation.

Expand and collapse form fields ​

Loading example…
Expand and collapse form fields

Dynamic form fields ​

Loading example…
Dynamic form fields

Attribute ​

parametersDescriptionTypeOptional valueDefault value
modelform data objectobject——
rulesform validation rulesobject——
inlineInline form modeboolean—false
label-positionThe position of the form field label. If the value is left or right, label-width needs to be set.stringright/left/topright
label-widthThe width of the form field label, for example '50px'. Form-item elements that are direct children of Form inherit this value. Support auto.string——
label-suffixSuffix for form field labelsstring——
hide-required-asteriskWhether to hide the red asterisk next to the label of a required fieldboolean—false
show-messageWhether to display verification error informationboolean—true
inline-messageWhether to display verification information inlineboolean—false
status-iconWhether to display the verification result feedback icon in the input boxboolean—false
validate-on-rule-changeWhether to trigger a verification immediately after the rules attribute changesboolean—true
sizeControl the size of components in the form; compatible with mini→small, medium→default.stringmedium/small/miniundefined
disabledWhether to disable all components within this form. If set to true, the disabled attribute on components within the form will no longer take effect.boolean—false
showBtnWhether to enable the fold button functionboolean—true
columnsFold when exceeding the specified number; retain the first columns-1 participants and the last operation item when folding.number—3
upIconCollapse button icon class name; defaults to built-in SVG.string—'icon-xiangshang2'
downIconExpand button icon class name; uses built-in SVG by default.string—'icon-xiangxia2'
isCollapseInitialize whether to foldboolean—true
expandBtnTypeExpand button typestringprimary/success/warning/danger/info/text/default''
expandBtnIconExpand button iconstring—undefined
expandBtnPlainExpand button plainboolean—true
expandBtnSizeExpand button size, the default is based on the form size. It is worth noting that after setting this, if it is not a value in the enumeration, it will be regarded as the default size of the button (the default maximum size, equivalent to large)stringmedium/small/miniundefined
expandBtnRoundExpand button roundboolean—false
expandBtnCircleExpand buttoncircleboolean—false
expandBtnLoadingExpand button loadingboolean—false
expandBtnDisabledExpand buttondisabledboolean—false
expandBtnTooltipDescExpand button tooltip text.string—Follow language pack
shrinkBtnTooltipDescCollapse button text.string—Follow language pack

Methods ​

method nameDescriptionparameters
validateA method for validating the entire form. The parameter is a callback function. This callback function will be called after the verification is completed, and two parameters will be passed in: whether the verification was successful and the fields that failed the verification. If no callback function is passed in, a promise will be returnedFunction(callback: Function(boolean, object))
validateFieldHow to verify some form fieldsFunction(props: array
resetFieldsReset the entire form, reset all field values to their initial values and remove validation results—
clearValidateRemove the validation results from the form item. Pass in the prop attribute or array of props of the form item to be removed. If not passed, the verification result of the entire form will be removed.Function(props: array
scrollToField(prop)Scroll to the specified field.string
getField(prop)Get field context.string
getFormItems()Refresh dynamic form item order.—

Event ​

event nameDescriptioncallback parameters
validateTriggered after any form item is verifiedThe form item being validated prop Value, whether the verification passed, error message (if present)
isCollapseChangeTriggered by change of form expansion state, true means expansion.expanded: boolean

Slot ​

NameDescription
defaultForm content; use NfFormItem to register the collapse item.

nf-form-item Attribute ​

parametersDescriptionTypeOptional valueDefault value
hiddenControls whether the form item participates in the hidden drop-down function, true does not participateboolean—false
propForm field model field, this attribute is required when using the validate and resetFields methods.stringincoming Form component model fields in—
labellabel textstring——
label-widthThe width of the form field label, for example '50px'. 'auto' is supported.string——
requiredIs it required? If not set, it will be automatically generated based on the verification rules.boolean—false
rulesform validation ruleobject——
errorForm field validation error message. Setting this value will change the form validation status to error and display the error message.string——
show-messageWhether to display verification error informationboolean—true
inline-messageDisplay verification information inlineboolean—false
sizeUsed to control the size of components under this form fieldstringmedium/small/mini-

nf-form-item Slot ​

NameDescription
defaultContents of Form Item
labelThe content of the label text

nf-form-item Scoped Slot ​

NameDescription
errorCustomize the display mode of form verification information, the parameter is

nf-form-item Methods ​

method nameDescriptionparameters
resetFieldReset the form item, reset its value to its initial value and remove the verification result-
clearValidateRemove the verification result of this form item-

Instructions for use ​

The hidden of NfFormItem means that it does not participate in folding and remains on the page. Validation, reset, and field methods use Element Plus's public API; do not rely on Vue 2 private instances.