PinInput
分格输入验证码或短文本。
实时预览
正在加载预览…
参数配置
全部字段 16
PinInputOptions
Go 代码
Go
// Inside a view; c is *ui.Context, t is nui.Theme.
// Keep s (example state) outside the view. See the complete example.
nui.PinInput(c.Key("pin"), t, &s.Value, &s.Pin, nui.PinInputOptions{Label: "Verification code", Length: 6, Numeric: true, Mask: false, ReadOnly: false, Disabled: false, Color: nui.ColorDefault, Size: nui.SizeDefault, Variant: nui.VariantDefault})使用说明
按格输入验证码,比较长度、数字限制与遮蔽显示。PinInputState 保留编辑位置;示例仅演示输入,不发送短信或验证身份。
API 参考
PinInput
源码func PinInput(c *ui.Context, t Theme, value *string, s *PinState, o PinInputOptions) ui.ElementPinInputOptions
源码type PinInputOptions struct {
Label string
Length int
Disabled, Mask bool
Numeric, ReadOnly bool // Text is the default; Numeric keeps only ASCII digits.
Placeholder string
Color Color
Variant Variant
Size Size
Separator []int // Insert a separator after these 1-based slots.
SeparatorEvery int // Insert after every N slots; Separator also applies.
OnChange, OnComplete func(string)
Decoration
}| 字段 | 类型 | 说明 |
|---|---|---|
Label | stringGo 零值: | 控件标签或可访问名称。 |
Length | intGo 零值: | 验证码输入格数。 |
Disabled | boolGo 零值: | 禁用组件及其交互。 |
Mask | boolGo 零值: | 遮蔽验证码字符。 |
Numeric | boolGo 零值: | 仅允许数字字符。 |
ReadOnly | boolGo 零值: | 允许读取和选择内容,但禁止编辑。 |
Placeholder | stringGo 零值: | 没有输入或选择时的占位文字。 |
Color | ColorGo 零值: | 语义颜色;默认值继承主题或组件配色。 |
Variant | VariantGo 零值: | 组件外观样式,支持范围取决于组件。 |
Size | SizeGo 零值: | 组件尺寸;默认值继承主题或组件尺寸。 |
Separator | []intGo 零值: | 在指定的 1 基位置后插入分隔符。 |
SeparatorEvery | intGo 零值: | 每隔指定格数插入分隔符。 |
OnChange | func(string)Go 零值: | 值发生变化时通知应用的回调。 |
OnComplete | func(string)Go 零值: | 输入完整值时通知应用的回调。 |
UI | StylesGo 零值: | 以部件名称为键覆盖外观和间距。 |
Style | func(Slot, ui.Element)Go 零值: | 同步配置当前构建的部件;不要保留 Element。 |