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

Summary of commonly used commands for docker competition submission

Log in to your account export DOCKER_REGISTRY=reg...

CSS 3.0 text hover jump special effects code

Here is a text hovering and jumping effect implem...

Implementation of docker redis5.0 cluster cluster construction

System environment: Ubuntu 16.04LTS This article ...

How to use html2canvas to convert HTML code into images

Convert code to image using html2canvas is a very...

Steps to deploy ingress-nginx on k8s

Table of contents Preface 1. Deployment and Confi...

Discuss the application of mixin in Vue

Mixins provide a very flexible way to distribute ...

Write a formal blog using XHTML CSS

The full name of Blog should be Web log, which mea...

Detailed analysis of compiling and installing vsFTP 3.0.3

Vulnerability Details VSFTP is a set of FTP serve...

MySQL 5.7 JSON type usage details

JSON is a lightweight data exchange format that u...

A brief introduction to Linux performance monitoring commands free

When the system encounters various IO bottlenecks...

One-click installation of MySQL 5.7 and password policy modification method

1. One-click installation of Mysql script [root@u...

MySQL briefly understands how "order by" works

For sorting, order by is a keyword we use very fr...