外观
PinInput 分格 PIN 输入
将短代码拆为多个独立输入格,逐格移动焦点并支持遮挡字符。
import { SPinInput } from '@icecreamqaq/shadcn/pin-input'使用示例
常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SPinInput.type | "text" | "number" | 默认 text。文本模式绑定 string[],数字模式绑定 (number | undefined)[]。 |
SPinInput.mask | boolean | 隐藏输入格中字符的可读内容,适合填写 PIN。 |
SPinInput.otp | boolean | 默认 true,允许浏览器识别一次性验证码。 |
SPinInputSlot.index | number | 必填,从 0 开始标识每个输入格的位置。 |
SPinInput.@complete | (value) => void | 所有已挂载的输入格都填好时触发,回传相应类型的数组。 |
完整 API
PinInput18 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
modelValue | PinInputValue<Type> | null |
defaultValue | PinInputValue<Type> |
placeholder | string |
mask | boolean |
otp | boolean |
requireComplete | boolean |
type | Type |
dir | Direction |
disabled | boolean |
id | string |
asChild | boolean |
as | AsTag | Component |
name | string |
required | boolean |
事件
| 名称 | 类型 |
|---|---|
update:modelValue | ((value: [Type] extends ["number"] ? (number | undefined)[] : string[]) => any) |
complete | ((value: [Type] extends ["number"] ? (number | undefined)[] : string[]) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
PinInputGroup4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
PinInputSeparator3 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
PinInputSlot5 个成员
属性
| 名称 | 类型 |
|---|---|
index 必填 | number |
disabled | boolean |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
分组导出
模板标签为 <s-pin-input>。
组件 SPinInput、SPinInputGroup、SPinInputSeparator、SPinInputSlot