vue验证码组件


1、效果图

  

2、全部代码:

  

<template>
    <div class="join_formitem">
                <label class="enquiry">验证码  <span>:</span></label>
                <div class = 'captcha'>
                    <input type="text" placeholder="请输入验证码" class="yanzhengma_input" v-model="picLyanzhengma">
                    <input type="button"  @click="createCode"  class="verification" v-model="checkCode"/>
                </div>
            </div>
</template>

methods:{ 
// 图片验证码 createCode(){ //先清空验证码的输入 this.code = ""; this.checkCode = ""; this.picLyanzhengma = ""; //验证码的长度 var codeLength = 4; //随机数 var random = new Array(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); for(var i = 0; i
< codeLength; i++) { //取得随机数的索引(0~35) var index = Math.floor(Math.random()*36); //根据索引取得随机数加到code上 this.code += random[index]; } //把code值赋给验证码 this.checkCode = this.code; }
}

css:

.yanzhengma_input{
        font-family: 'Exo 2', sans-serif;
    border: 1px solid #fff;
    color: #fff;
    outline: none;
    border-radius: 12px;
    letter-spacing: 1px;
    font-size: 17px;
    font-weight: normal;
        background-color: rgba(82, 56, 76, 0.15);
        padding: 5px 0 5px 10px;
    margin-left: 30px;
    height: 30px;
    margin-top: 25px;
    border: 1px solid #e6e6e6;
}
.verification{
    border-radius: 12px;
    width:100px;
    letter-spacing:5px;
    margin-left: 50px;
    height: 40px;
    transform: translate(-15px,0);
}
.captcha{
    height: 50px;
    text-align: justify;
}

优质内容筛选与推荐>>
1、python之项目依赖管理
2、WPF笔记(4.3 集合数据绑定)——Data Binding
3、UI Automation Basic Summary
4、一些常用命令
5、在boost.foreach中操作迭代器


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号





    联系我们

    欢迎来到TinyMind。

    关于TinyMind的内容或商务合作、网站建议,举报不良信息等均可联系我们。

    TinyMind客服邮箱:support@tinymind.net.cn