zoukankan      html  css  js  c++  java
  • Vue -- 验证码

    <template>
    <div>
    <p>随机生成验证码:</p>
    <p>{{yzm}}</p>
    <input type="text" v-model="inp" />
    <button @click="getCode">看不清换一个</button>
    <button @click="checkCode" @keyup.enter="checkCode">验证</button>
    <span>{{jg}}</span>
    </div>
    </template>
    <script>
    export default {
    data(){
    return{
    yzm:'1234',
    inp:'',
    jg:''
    }
    },
    mounted(){
    this.getCode()
    },
    methods:{
    getCode(){
    const random = [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']
    let code = ''
    for(let i=0;i<4;i++){
    let index = Math.floor(Math.random()*36)
    code = code + random[index]
    }
    this.yzm = code
    },
    checkCode(){
    this.inp = this.inp.toUpperCase()
    if(this.inp == this.yzm){
    this.jg = true
    }else{
    this.jg = false
    }
    }
    }
    }
    </script>
    <style scoped>

    </style>

  • 相关阅读:
    从DataGridViewer导出Excel
    C#获取特定进程CPU和内存使用率
    51 nod 1265 四点共面
    51nod 1384 全排列
    51nod 2006 飞行员配对
    codeforces 839A
    codeforce 837C
    codeforces 837B
    codoforces 837A
    GIT
  • 原文地址:https://www.cnblogs.com/q0024/p/14115495.html
Copyright © 2011-2022 走看看