zoukankan      html  css  js  c++  java
  • uniapp vue中的短信验证码

    <template>
        <view class="content">
            <view class="input-item yzs">
                <text class="tit">验证码</text>
                <button class="tit" @tap="sendCode" :disabled="disabled">{{send}}</button>
            </view>
        </view>
    </template>
    <script>
        export default {
            data() {
                return {
                    disabled:false,
                    send:'发送验证码'
                }
            },
            methods: {
                sendCode(){
                    let self = this
                    //验证码
                    self.disabled = true;
                    var time = 10;                //时间为10s,可以按情况更改 
                    var timer = setInterval(fun, 1000);  //设置定时器 
                    function fun() { 
                        time--; 
                        if(time>=0) { 
                            self.send = time + "s后重新发送"; 
                        }else if(time<0){ 
                            self.send = "重新发送验证码"; 
                            self.disabled = false;  //倒计时结束能够重新点击发送的按钮 
                            clearInterval(timer);  //清除定时器 
                            time = 10;  //设置循环重新开始条件 
                        } 
                    } 
                },
            }
        }
    </script>                        

    有错误请告诉我,我会及时改正,谢谢

    有问题可直接留言,望各位与我都可以成为技术大牛。
  • 相关阅读:
    HDU 4005 The war
    #undef
    [转载] #define new DEBUG_NEW
    [转载]常用正则表达式
    [百科]
    [转载]
    [转载]
    [转载]
    [百科]
    [转载]VC6中的文件后缀
  • 原文地址:https://www.cnblogs.com/xhxdd/p/11939716.html
Copyright © 2011-2022 走看看