您好,登錄后才能下訂單哦!
這篇文章主要講解了“vue驗證碼組件怎么使用”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“vue驗證碼組件怎么使用”吧!
代碼如下:
<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 // 隨機數 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 } } } </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>
感謝各位的閱讀,以上就是“vue驗證碼組件怎么使用”的內容了,經過本文的學習后,相信大家對vue驗證碼組件怎么使用這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。