VEUI

VEUI on GitHub
Play!中文

Field

Examples

See Form examples.

API

Props

NameTypeDefaultDescription
uistring-

Predefined style.

ValueDescription
xsExtra small size style.
sSmall size style.
mMedium size style.
lLarge size style.
readonlybooleanfalseWhether the internal input component is in read-only state.
disabledbooleanfalseWhether the internal input component is disabled.
labelstring-Form item title.
tipstring-Form item floating layer prompt content.
namestring-Form item name, which can be used to specify the data field name or display error message location.
fieldstring-

Optional, the default value is the value of the name property. In special cases, it is used to specify the path of the form data property corresponding to the field.

ValueDescription
usernameCorresponds to the username property of the form data attribute reference value, equivalent to data.username.
users[0]Equivalent to data.users[0].
user.usernameEquivalent to data.user.username.
rulesstring | Array<Object>-

Validation rules for form items, which perform synchronous single-value validation. For the Array type, the item type is {triggers, name, message, value, validate, priority}.

NameTypeDescription
triggersstringA collection of event names that trigger validation, separated by commas, supports <fieldName>:<eventName> to indicate that the validation is triggered when the fieldName field triggers the eventName event, refer to the example Inline Rule Validation.
namestringRule name.
value*The value that the rule should match. For boolean type rules, the default value is true.
messagestring | function

Error message that can override the default rule error message.

If the type is string, {ruleValue} can be referenced with {ruleValue} and value can be referenced with {value}. For example:

let minLengthRule = {
  validate (value, ruleValue) {
    return !isEmpty(value) ? val.length >= ruleValue : true
  },
  message: 'The character length cannot be less than {ruleValue}, current length {value}',
  priority: 100
}

If the type is function, the parameter is (ruleValue: ?*=, value: *). For example:

let minLengthRule = {
  validate (value, ruleValue) {
    return !isEmpty(value) ? val.length >= ruleValue : true
  },
  message (ruleValue, value) {
    return `The character length cannot be less than ${ruleValue}, current length ${value}`
  },
  priority: 100
}
prioritynumberThe priority of the rule, which can override the default priority.
validate(value: unknown, ruleValue: unknown) => booleanAn inline validator used to directly write validation logic, refer to the example Inline Rule Validation.
NameTypeDescription
requiredbooleanThe value cannot be a null value (null / undefined / '' / []).
numericbooleanThe value must be describable as a decimal number.(6 / 66.6 / 6e6 / '6' / .6)
patternRegExp | stringRegular expression matching.
maxLengthnumberThe value's length property cannot be greater than the limit.
minLengthnumberThe value's length property cannot be less than the limit.
maxnumberThe value cannot be greater than the limit.
minnumberThe value cannot be less than the limit.
helpstring-Form item auxiliary text.
help-position'bottom' | 'side''side'

The display position of the form item's auxiliary text.

ValueDescription
sideThe auxiliary text is displayed on the side of the form item.
bottomThe auxiliary text is displayed below the form item, before the validation message.
abstractbooleanfalseAbstract form item, abstract items have no title and will not display validation information.
withhold-validitybooleanfalseWhen set to true, the input components (such as veui-input) in the content of this form item will not automatically bind validation events or enter the invalid state, and the user can customize it through the default slot.
validity-display'normal' | 'simple''simple'

Whether the validation message of the form item is displayed with an icon.

ValueDescription
normalThe validation message is displayed with an icon.
simpleThe validation message is not displayed with an icon.
requiredbooleanfalseWhether to display a star symbol indicating the necessity when there is no required rule.

Slots

NameDescription
defaultUsed by inline input components. Slot props include: (listeners: object, invalid: boolean, validities: object, readonly: boolean, disabled: boolean), where invalid indicates whether the current form item has failed validation, listeners are event bindings for validation, and validities are validation messages.
labelFills the content of the form item description. Defaults to the text value of the label prop.
tipFills the content of the form item tooltip. Defaults to the text value of the tip prop.
helpContent of the form item's auxiliary text. Defaults to the text value of the help prop.

Icons

NameDescription
tipThe icon that triggers the tooltip.

Configs

OptionTypeDefaultDescription
field.validityDisplay'normal' | 'simple''simple'See the validity-display prop.

CSS

NameTypeDefaultDescription
--dls-field-label-width<length>-The width of the form item label.
Edit this page on GitHubEdit
© Baidu, Inc. 2024