更新记录
1.0.0(2025-03-03)
下载此版本
发布初版
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
app-vue |
× |
√ |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
鸿蒙元服务 |
× |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
√ |
Code 验证码输入框
组件名: xt-code
安装方式
本组件符合 easycom 规范,HBuilderX 3.1.0 起,只需将本组件导入项目,在页面 template 中即可直接使用,无需在页面中 import 和注册 components
基本用法
<template>
<view class="xt">
<xt-code v-model='code' @complete="complete" @confirm="confirm"></xt-code>
<xt-code type="bottom" @complete="complete" @confirm="confirm"></xt-code>
<xt-code type="middle" @complete="complete" @confirm="confirm"></xt-code>
</view>
</template>
<script>
export default {
data() {
return {
code: '123'
}
},
methods: {
complete(e) {
console.log(e);
},
confirm(e) {
console.log(e);
}
}
}
</script>
<style scoped>
.xt {
padding: 50rpx;
display: flex;
flex-direction: column;
gap: 50rpx;
}
</style>
API
属性 |
类型 |
默认值 |
描述 |
value |
String |
- |
绑定的值 |
fontSize |
String |
30rpx |
字体大小 |
size |
String |Number |
60rpx |
输入框大小 |
color |
String |
#303133 |
字体颜色 |
cursorColor |
String |
#1e90ff |
光标颜色 |
inactiveColor |
String |
#a4b0be |
输入框未激活时的颜色 |
activeColor |
String |
#409EFF |
输入框激活时的颜色 |
type |
String |
box |
输入框类型,可选 middle ,bottom |
count |
Number |
4 |
验证码位数 |
stick |
Boolean |
false |
是否开启粘贴 |
Event
事件名 |
类型 |
说明 |
complete |
Function |
位数达标事件 |
confirm |
Function |
完成事件 |
paste |
Function |
粘贴事件 |