更新记录

1.0.0(2024-03-12)

  • 第一版

平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.6.4 app-vue × × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari

x-code-input

在插件市场,找了两个类似的插件,看到评论区,各种删除不了的小问题;自己写了版本

uniapp 验证码/密码输入框

  • 支持vue2,vue3;支持h5,app安卓(亲测可用);其他小程序未测,估计问题不大;
  • 设置焦点,自动唤醒系统键盘,记得使用延迟执行!
  • 一些细节的UI样式,圆角,字体大小,输入框的小竖杠;请直接改源码即可

属性说明

  • this.$refs.xcodeinputRef.clear();清空并获取焦点
属性 是否必填 值类型 默认值 说明
inputType String number number/text
length Number 6 长度
showVal Boolean true 显示输入的内容/星号*
width String 99 宽度
height String 99 高度
backgroundColor String F6F6F6 背景色
bold Boolean true 字体是否加粗
@confirm Function Object 输入完成回调

完整示例

<template>
    <view class="demo">
        <xcodeinput ref="xcodeinputRef" :width="99" :height="99" backgroundColor="#F6F6F6" bold showVal :length="4"
            @confirm="inputConfirm" />
    </view>
</template>

<script>
    import xcodeinput from "@/uni_modules/x-code-input/components/x-code-input/x-code-input.vue";

    export default {
        components: {
            xcodeinput,
        },
        data() {
            return {};
        },
        methods: {
            inputConfirm(value) {
                console.log(value);
            },
            onConfirm() {
                setTimeout(() => {
                    // 清空并获取焦点;若使用vue3 setup语法,ref方法有所改变;
                    // 安卓手机多次点击,偶尔会弹不出来输入法;所以这个地方使用一个延迟执行!!!
                    this.$refs.xcodeinputRef.clear();
                }, 222);
            }
        },
    };
</script>

隐私、权限声明

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

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

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

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问