CodeInput (验证码输入)
组件用于输入验证码的高交互性组件,具有以下功能亮点:支持自定义样式、光标动画效果、显示或隐藏输入字符,适用于各种验证场景。使用场景包括登录、注册、身份验证等需要用户输入验证码的界面
支持平台
| 安卓 | ios | 鸿蒙 | web | 微信小程序 |
|---|---|---|---|---|
| √ | √ | √ | √ | √ |
示例代码
html
<template>
<t-page title="验证码输入">
<t-card title="CodeInput" main-class="mtlr-20"
sub-title="组件用于输入验证码的高交互性组件,具有以下功能亮点:支持自定义样式、光标动画效果、显示或隐藏输入字符,适用于各种验证场景。使用场景包括登录、注册、身份验证等需要用户输入验证码的界面"></t-card>
<!-- https://cloud.tencent.com/developer/article/2177661 emoji -->
<introduction title="点模式">
<t-code-input main-class="mb-20" v-model="codeNumber1" dotSymbol="*"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber1" type="primary" dotSymbol="🍑"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber1" type="success" dotSymbol="🍄"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber1" type="error"
item-box-class="r-0 brw-0 btw-0 blw-0 mr-20" dotSymbol="🌶️"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber1" type="warning"
item-box-class="r-0 brw-0 btw-0 blw-0 mr-20" dotSymbol="🍆"></t-code-input>
</introduction>
<introduction title="基础功能-type">
<t-code-input main-class="mb-20 tdr tdb tdp" v-model="codeNumber1"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" v-model="codeNumber1" type="info"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" v-model="codeNumber1" type="primary"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" v-model="codeNumber1" type="success"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" v-model="codeNumber1" type="error"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" v-model="codeNumber1" type="warning"></t-code-input>
</introduction>
<t-lazy>
<introduction title="基础功能-size-光标样式">
<t-code-input main-class="mb-20 tdr tdb tdp" size="large" item-box-class="fv" cursorClass="w-30 h-10"
type="primary"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" size="medium" item-box-class="fv" cursorClass="w-20 h-10"
type="success"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" size="small" item-box-class="fv" cursorClass="w-10 h-10"
type="error"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" size="mini" item-box-class="fv" cursorClass="w-5 h-10"
type="warning"></t-code-input>
</introduction>
</t-lazy>
<t-lazy>
<introduction title="基础功能-effect-禁用展示">
<t-code-input main-class="mb-20 tdr tdb tdp" size="large" item-box-class="fv" :disabled="true"
cursorClass="w-30 h-10" type="primary" effect="normal"></t-code-input>
<t-code-input main-class="mb-20 tdr tdb tdp" size="large" item-box-class="fv" cursorClass="w-20 h-10"
:disabled="true" type="primary" effect="dark"></t-code-input>
</introduction>
</t-lazy>
<t-lazy>
<introduction title="横线模式">
<t-code-input main-class="mb-20" item-box-class="r-0 brw-0 btw-0 blw-0" mode="line"></t-code-input>
<t-code-input main-class="mb-20" item-box-class="r-0 brw-0 btw-0 blw-0" mode="line"
type="primary"></t-code-input>
<t-code-input main-class="mb-20" item-box-class="r-0 brw-0 btw-0 blw-0" mode="line"
type="success"></t-code-input>
<t-code-input main-class="mb-20" item-box-class="r-0 brw-0 btw-0 blw-0" mode="line"
type="error"></t-code-input>
<t-code-input main-class="mb-20" item-box-class="r-0 brw-0 btw-0 blw-0" mode="line"
type="warning"></t-code-input>
</introduction>
</t-lazy>
<t-lazy>
<introduction title="默认值">
<t-code-input main-class="mb-20" v-model="codeNumber6"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber6" type="primary"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber6" type="success"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber6" type="error"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber6" type="warning"></t-code-input>
</introduction>
</t-lazy>
<t-lazy>
<introduction title="设置长度">
<t-code-input main-class="mb-20" v-model="codeNumber1" :maxlength="2"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber1" :maxlength="3" type="primary"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber1" :maxlength="4" type="success"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber1" :maxlength="5" type="error"></t-code-input>
<t-code-input main-class="mb-20" v-model="codeNumber1" :maxlength="7" type="warning"></t-code-input>
</introduction>
</t-lazy>
</t-page>
</template>
<script>
export default {
data() {
return {
codeNumber1: '',
codeNumber2: '',
codeNumber3: '',
codeNumber4: '',
codeNumber5: '',
codeNumber6: '125',
};
}
}
</script>属性
| 名称 | 类型 | 默认值 | 说明 | 可选值 |
|---|---|---|---|---|
| size | String | mini | 组件尺寸 | large(大尺寸), medium(中尺寸), small(小尺寸), mini(迷你) |
| type | String | "" | 组件类型 | info(信息), primary(正常), error(错误), warning(警告), success(成功) |
| disabled | Boolean | false | 组件是否禁用 | false, true |
| stop | Boolean | false | 是否阻止事件冒泡(Tui统一写法处理事件冒泡) | false, true |
| hover | Boolean | true | 是否有点击效果 | false, true |
| path | String | "" | 点击组件后跳转的页面路径,如果为空则响应点击事件,如果不为空则跳转页面不会响应单击事件。 | - |
| mainClass | String | "" | 组件根节点的样式 | - |
| nativeClass | String | "" | 组件根节点原生样式 | - |
| effect | String | "normal" | 组件显示主题 | normal(正常), dark(深色), light(浅色), plain(镂空) |
| type | String | p | ||
| editBoxClass | String | `` | 编辑框例子的样式 | |
| maxlength | Number | 6 | 最大输入长度 | |
| dotSymbol | String | `` | 输入字符的替换占位字符 | |
| dotSymbolClass | String | `` | 替换占位字符的样式 | |
| modelValue | String | `` | 验证码输入的值 | |
| autoFocus | Boolean | false | 是否自动获取焦点 | |
| cursorClass | String | `` | 光标样式 | |
| textClass | String | `` | 文本样式 | |
| itemBoxClass | String | `` | 子盒子的样式 | |
| activeItemItemBoxClassClass | String | `` | 当前正在输入的元素的盒子样式 | |
| inactiveItemItemBoxClassClass | String | b-2px,s,#ccc | 当前未输入状态元素的盒子样式 | |
| inputType | String | text | 输入框inputinput的类型 ,同官方input的type | text: 文本输入键盘number: 数字输入键盘idcard: 身份证输入键盘digit: 带小数点数字输入键盘tel: 电话输入键盘safe-password: 密码安全输入键盘nickname: 昵称输入键盘 |
事件
| 名称 | 返回参数 | 说明 |
|---|---|---|
| change | 输入的内容 | 输入框的值化生变化时触发 |
方法
| 名称 | 参数 | 返回值 | 说明 |
|---|---|---|---|
| onBlur | - | - | |
| onFocus | - | - |
