Detailed explanation of how to use the vue verification code component

Detailed explanation of how to use the vue verification code component

This article example shares the specific implementation code used by the vue verification code component for your reference. The specific content is as follows

The code is as follows:

<template>

     <div class="join_formitem">
       <label class="enquiry">Verification code<span>:</span></label>
       <div class="captcha">
         <input type="text" placeholder="Please enter the verification code" 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:'' //..Verification code image}
  },
  created(){
    this.createdCode()
  },
  methods: {
    // Image verification code createdCode(){
      // Clear the verification code first this.code = ""
      this.checkCode = ""
      this.picLyanzhengma = ""
      //Verification code length const codeLength = 4
      // Random numbers 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++){
        // Get the index of the random number (0~35)
        let index = Math.floor(Math.random() * 36)
        // Get the random number based on the index and add it to code this.code += random[index]
      }
      // Assign the code value to the verification 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> 

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Vue3.0 implements click-to-switch verification code (component) and verification
  • Vue implements an example code of the verification code input component function with 6 input boxes
  • Encapsulation implementation of Vue random verification code component
  • Vue gets the verification code countdown component
  • Sample code of the verification code component based on vue
  • Vue verification code component application example
  • Vue implements verification code input box component
  • How to add mobile verification code component function in Vue
  • Detailed explanation of Vue SMS verification code component development

<<:  Solve the problem of changing the password when logging in for the first time after installing MySQL 8.0

>>:  How to install PHP7.4 and Nginx on Centos

Recommend

Implementation of MySQL Shell import_table data import

Table of contents 1. Introduction to import_table...

Use of Linux passwd command

1. Command Introduction The passwd command is use...

Summary of using the exclamation mark command (!) in Linux

Preface Recently, our company has configured mbp,...

A brief summary of basic web page performance optimization rules

Some optimization rules for browser web pages Pag...

Discussion on default margin and padding values ​​of common elements

Today we discussed the issue of what the margin v...

Detailed explanation of the basic commands of Firewalld firewall in Centos7

1. Basics of Linux Firewall The Linux firewall sy...

Binary Search Tree Algorithm Tutorial for JavaScript Beginners

Table of contents What is a Binary Search Tree (B...

A detailed discussion of components in Vue

Table of contents 1. Component Registration 2. Us...

Detailed explanation of Vue's keyboard events

Table of contents Common key aliases Key without ...

Summary of Nginx load balancing methods

To understand load balancing, you must first unde...

Why does MySQL database index choose to use B+ tree?

Before further analyzing why MySQL database index...

HTML iframe usage summary collection

Detailed Analysis of Iframe Usage <iframe frame...

Summary of WEBAPP development skills (notes for mobile website development)

1. To develop web responsively, the page must ada...

How to monitor mysql using zabbix

Zabbix deployment documentation After zabbix is ​...

Use of Linux crontab command

1. Command Introduction The contab (cron table) c...