java生成验证码在vue显示_vue验证码组件应用实例

代码如下:

验证码:

export default {

data(){

return{

code:'',

checkCode:'',

picVerification:'' //..验证码图片

}

},

created(){

this.createdCode()

},

methods: {

// 图片验证码

createdCode(){

// 先清空验证码输入

this.code = ""

this.checkCode = ""

this.picVerification = ""

// 验证码长度

const codeLength = 4

// 随机数

const 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(let i = 0;i < codeLength;i++){

// 取得随机数的索引(0~35)

let index = Math.floor(Math.random() * 36)

// 根据索引取得随机数加到code上

this.code += random[index]

}

// 把code值赋给验证码

this.checkCode = this.code

}

}

}

.verification_input{

font-family: 'Exo 2',sans-serif;

border: 1px solid #fff;

color: black;

outline: none;

border-radius: 12px;

letter-spacing: 1px;

font-size: 17px;

font-weight: normal;

background-color: rgba(82,56,76,.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;

}

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对脚本之家的支持。如果你想了解更多相关内容请查看下面相关链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值