vue驗證碼組件使用方法詳解
更新時間:2021年07月11日 17:26:21 作者:UIEngineer
這篇文章主要為大家詳細介紹了vue驗證碼組件的使用方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了vue驗證碼組件使用的具體實現(xiàn)代碼,供大家參考,具體內(nèi)容如下
代碼如下:
<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="createdCode" class="verification" v-model="checkCode" /> </div> </div> </template> <script> export default { data(){ return{ code:'', checkCode:'', picLyanzhengma:'' //..驗證碼圖片 } }, created(){ this.createdCode() }, methods: { // 圖片驗證碼 createdCode(){ // 先清空驗證碼輸入 this.code = "" this.checkCode = "" this.picLyanzhengma = "" // 驗證碼長度 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> .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,.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>
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue3路由跳轉(zhuǎn)params傳參接收不到的解決辦法
這篇文章主要給大家介紹了關(guān)于vue3路由跳轉(zhuǎn)params傳參接收不到的解決辦法,Vue3是目前前端開發(fā)中非常流行的框架之一,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2023-06-06vue3.0使用taro-ui-vue3引入組件不生效的問題及解決
這篇文章主要介紹了vue3.0使用taro-ui-vue3引入組件不生效的解決方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-03-03Vue+Element+Springboot圖片上傳的實現(xiàn)示例
最近在學習前段后分離,本文介紹了Vue+Element+Springboot圖片上傳的實現(xiàn)示例,具有一定的參考價值,感興趣的可以了解一下2021-11-11Vuejs 用$emit與$on來進行兄弟組件之間的數(shù)據(jù)傳輸通信
本篇文章主要介紹了Vuejs 用$emit 與 $on 來進行兄弟組件之間的數(shù)據(jù)傳輸示例,非常具有實用價值,需要的朋友可以參考下。2017-02-02vue實現(xiàn)的上拉加載更多數(shù)據(jù)/分頁功能示例
這篇文章主要介紹了vue實現(xiàn)的上拉加載更多數(shù)據(jù)/分頁功能,涉及基于vue的事件響應、數(shù)據(jù)交互等相關(guān)操作技巧,需要的朋友可以參考下2019-05-05