专业安装快速启动 :rocket:

Basic example

The currency input allows for restricted input of values based on the provided currency and locale.

加载实时示例

Props

Currency

The currency prop is the three letter currency code and sets the proper formatting for the specified currency. For a full list of supported currency types check: https://en.wikipedia.org/wiki/ISO_4217#List_of_ISO_4217_currency_codes

Locale

By default, the locale used will be that of what is set in your formkit.config.ts. This can be overriden with the display-locale prop. For example, en, de, en-IN, zh-CN, etc, etc.

加载实时示例

Currency Additional Props

Decimals

If you would like to prevent decimals from being displayed, set decimals to false or 0.

You can also choose to set a minimum number of decimals with the min-decimals prop. For example, setting the prop min-decimals="2" will always show 2 decimal points.

Minimum and Maximum Values

Setting the props min or max will prevent entry of a higher or lower value.

Step

Value scan be incremented and decremented by use of the up/down keys. The degree by which the value changes is determined by the step prop.

加载实时示例

Props & Attributes

PropType默认描述
currencystringUSDSet the specified currency to use for this input
displayLocalestringen-USSet the desired display locale to use for this input
decimalsboolean|numbernullChoose to either completely disallow decimals or override the maximum number of decimals for the input
minDecimalsnumbernullChoose to show a minimum number of decimals should your input require this
minnumbernullMinimum numeric value allowed. If zero or above, negatives will not be allowed
maxnumbernullMaximum numeric value allowed for this input
stepnumber1When using the up/down keys, how much to modify the current value.
valueFormatstringnumberChoose between number and string whether you want a numeric value or a parsed string value
显示 通用 props
configObject{}提供给 input 的节点和此输入的任何后代节点的配置选项。
delayNumber20在调度 commit hook 前,输入值的去抖动毫秒数。
dirtyBehaviorstringtouched确定此输入的“dirty”标志设置方式。可以设置为 touchedcompare — 默认为 touched,性能更好,但无法检测表单是否再次匹配其初始状态。
errorsArray[]要在此字段上显示的错误消息的字符串数组。
helpString''帮助文本与输入关联的文本。
idStringinput_{n}输入的唯一标识符。提供一个 id 还可以全局访问输入的节点。
ignoreBooleanfalse防止将输入包含在任何父级(组、列表、表单等)中。在仅用于 UI 而不是实际值的情况下非常有用。
indexNumberundefined如果父级是列表,允许在给定索引处插入输入。如果输入的值未定义,它将继承该索引位置的值。如果它有一个值,它将在给定索引处将其插入到列表的值中。
labelString''与输入关联的 label 元素的文本。
nameStringinput_{n}输入的名称,在数据对象中唯一标识。在一组字段中应该是唯一的。
parentFormKitNodecontextual默认情况下,父级是包装组、列表或表单,但此属性允许显式分配父级节点。
prefix-iconString''指定放置在 prefixIcon 部分的 图标
preservebooleanfalse在输入卸载时,在父组、列表或表单上保留输入的值。
preserve-errorsbooleanfalse默认情况下,使用 setErrors 在输入上设置的错误会在输入时自动清除,将此属性设置为 true 可以保留错误,直到明确清除为止。
sections-schemaObject{}一个包含部分键和模式部分值的对象,其中每个模式部分应用于相应的部分。
suffix-iconString''指定放置在 suffixIcon 部分的 图标
typeStringtext要从库中渲染的输入类型。
validationString, Array[]要应用于输入的 验证 规则。
validation-visibilityStringblur确定何时显示输入的验证失败规则。有效值为 blurdirtylive
validation-labelString{label prop}确定在验证错误消息中使用的标签,默认情况下,如果可用,则使用 label 属性,否则使用 name 属性。
validation-rulesObject{}附加的自定义验证规则,可用于验证 prop。
valueAnyundefined为输入和/或其子元素提供初始值。不是响应式的。可以种子 整个组(表单)和列表。

Sections

您可以通过使用该部分的"key"来定位输入的特定部分,从而可以修改该部分的类、HTML(通过:sections-schema)或内容(通过插槽))。了解更多关于部分的信息,请点击这里

Currency input diagram

Currency Input
$1,234.56
How much do you want to donate?
That's a lot of money

Keyboard Interactions

键盘事件描述
Up + DownIncrements through input value by current step amount.
显示 通用 键盘事件
Tab将焦点移动到页面上的下一个可聚焦输入。
Shift + Tab将焦点移动到页面上的上一个可聚焦输入。