更新记录

1.0.0(2026-08-12) 下载此版本

1.0.0更新


平台兼容性

uni-app(4.0)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟

uni-app x(4.0)

Chrome Safari Android iOS 鸿蒙 微信小程序

ErCodeInput 分段输入框插件

验证码 / 密码 / 车牌号分段输入组件,支持颜色、字号、宽高、圆角自定义,隐秘输入,多种外观样式。兼容 uni-app(Vue2 / Vue3)uni-app x

安装

uni_modules/er-code-input 放入项目即可,支持 easycom 自动引入。

uni-app x

components-x/er-code-input/er-code-input.uvue 复制到项目组件目录,或按需引用该 uvue 文件。

组件

组件 说明
er-code-input 通用分段输入(mode: code / password / plate)
er-pwd-input 密码输入(默认隐秘 + 数字)
er-plate-input 车牌号输入(自带省份键盘,支持新能源)

快速使用

<template>
  <!-- 验证码 -->
  <er-code-input v-model="code" mode="code" :length="6" only-number box-style="box" @complete="onCode" />

  <!-- 密码 -->
  <er-pwd-input v-model="pwd" :length="6" box-style="underline" />

  <!-- 车牌(普通 7 位 / 新能源 8 位) -->
  <er-plate-input v-model="plate" :energy="false" />
  <er-plate-input v-model="plateNew" energy />
</template>

Vue2 也可使用 :value + @input

样式 box-style

效果
box 方框(默认)
underline 底边线
circle 圆形
line 中间横线(未输入时)
soft 无边框浅底

主要 Props

属性 类型 默认 说明
mode String code code / password / plate
length Number 6 位数(车牌由 energy 决定 7/8)
energy Boolean false 新能源车牌
boxStyle String box 外观样式
width / height String 88rpx 单格尺寸
gap String 16rpx 间距
radius String 12rpx 圆角
fontSize String 40rpx 字号
color String #1a1a1a 文字色
activeColor String #2b6de5 激活色
borderColor String #dcdfe6 边框色
bgColor String #ffffff 背景色
cursorColor String 光标色
password Boolean false 隐秘显示
maskChar String 掩码字符
onlyNumber Boolean false 仅数字
autoFocus Boolean false 自动聚焦
disabled Boolean false 禁用

事件

事件 说明
input / update:modelValue 值变化
change 值变化
complete 输入满位
focus / blur 聚焦 / 失焦

方法(ref)

  • clear() 清空
  • focus() 聚焦

示例:自定义外观

<er-code-input
  v-model="code"
  :length="4"
  box-style="soft"
  width="100rpx"
  height="100rpx"
  font-size="48rpx"
  color="#111"
  active-color="#e6a23c"
  bg-color="#f5f7fa"
  password
  mask-char="*"
/>

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

暂无用户评论。