vue驗證碼組件應(yīng)用實例
更新時間:2019年01月18日 08:37:20 作者:muzidigbig
今天小編就為大家分享一篇關(guān)于vue驗證碼組件應(yīng)用實例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
代碼如下:
<template>
<div class="join_formitem">
<label class="enquiry">驗證碼<span>:</span></label>
<div class="captcha">
<input type="text" placeholder="請輸入驗證碼" class="verification_input" v-model="picVerification" />
<input type="button" @click="createdCode" class="verification" v-model="checkCode" />
</div>
</div>
</template>
<script>
export default {
data(){
return{
code:'',
checkCode:'',
picVerification:'' //..驗證碼圖片
}
},
created(){
this.createdCode()
},
methods: {
// 圖片驗證碼
createdCode(){
// 先清空驗證碼輸入
this.code = ""
this.checkCode = ""
this.picVerification = ""
// 驗證碼長度
const codeLength = 4
// 隨機數(shù)
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++){
// 取得隨機數(shù)的索引(0~35)
let index = Math.floor(Math.random() * 36)
// 根據(jù)索引取得隨機數(shù)加到code上
this.code += random[index]
}
// 把code值賦給驗證碼
this.checkCode = this.code
}
}
}
</script>
<style>
.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;
}
</style>

總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接
相關(guān)文章
關(guān)于spring 掃描不到j(luò)ar中class文件的原因分析及解決
這篇文章主要介紹了關(guān)于spring 掃描不到j(luò)ar中class文件的原因分析及解決,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-08-08
Java代碼實現(xiàn)對properties文件有序的讀寫的示例
本篇文章主要介紹了Java代碼實現(xiàn)對properties文件有序的讀寫的示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-11-11
selenium4.0版本在springboot中的使用問題的坑
本文主要介紹了selenium4.0版本在springboot中的使用問題的坑,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2022-07-07
spring(java,js,html) 截圖上傳圖片實例詳解
這篇文章主要介紹了spring(java,js,html) 截圖上傳圖片實例詳解的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-07-07

