国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

Vue驗證碼60秒倒計時功能簡單實例代碼

2019-11-19 13:37:08
字體:
來源:轉載
供稿:網(wǎng)友

template

<template> <div class='login'> <div class="loginHeader">  <input type="tel" class="loginBtn border-bottom" placeholder="請輸入手機號" />  <input type="tel" class="codeBtn" placeholder="請輸入驗證碼" />  <input type="button" class="getNumber" v-model="codeMsg" @click="getCode" :disabled="codeDisabled" /> </div> </div></template>

script

<script> export default { data() {  return {  // 是否禁用按鈕  codeDisabled: false,  // 倒計時秒數(shù)  countdown: 60,  // 按鈕上的文字  codeMsg: '獲取驗證碼',  // 定時器  timer: null  } }, methods: {  // 獲取驗證碼  getCode() {  // 驗證碼60秒倒計時  if (!this.timer) {   this.timer = setInterval(() => {   if (this.countdown > 0 && this.countdown <= 60) {    this.countdown--;    if (this.countdown !== 0) {    this.codeMsg = "重新發(fā)送(" + this.countdown + ")";    } else {    clearInterval(this.timer);    this.codeMsg = "獲取驗證碼";    this.countdown = 60;    this.timer = null;    this.codeDisabled = false;    }   }   }, 1000)  }  } } }</script>

css(scss寫法)

<style>.login{ width: 100%; height: 100%; background: #F9F9F9; .loginHeader{ padding: 0 10px; background: #fff; margin-top: 20px; overflow: hidden; .loginBtn{  width: 100%;  height: 42px;  border: none;  background: #fff;  color: #444;  border-radius: 4px;  outline: none;  padding-left: 3px;  font-size: 1.4rem;  box-sizing: border-box;  -webkit-appearance:none; } .border-bottom{  border-bottom: 1px solid #F3F3F3; } .codeBtn{  width: 63%;  height: 42px;  border: none;  background: #fff;  color: #444;  border-radius: 4px;  float: left;  outline: none;  padding-left: 3px;  font-size: 1.4rem;  box-sizing: border-box;  -webkit-appearance:none; } .getNumber{  width: 35%;  height: 36px;  float: right;  margin-top: 3px;  border: 1px solid #09BB07;  color: #09BB07;  background: #fff;  border-radius: 4px;  outline: none;  -webkit-appearance:none; } }}</style>

總結

以上所述是小編給大家介紹的Vue驗證碼60秒倒計時功能簡單實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網(wǎng)網(wǎng)站的支持!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 嘉义市| 固安县| 邯郸市| 东方市| 商丘市| 龙游县| 永吉县| 南通市| 兴义市| 呼和浩特市| 宜宾县| 南平市| 黄陵县| 隆昌县| 渭南市| 林西县| 新化县| 汤原县| 延安市| 兴国县| 方正县| 两当县| 马鞍山市| 融水| 肥西县| 广汉市| 太谷县| 朝阳市| 祁东县| 定安县| 菏泽市| 石首市| 梓潼县| 湖南省| 汾西县| 合阳县| 陵水| 塘沽区| 靖安县| 台前县| 龙州县|