欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用vue實(shí)現(xiàn)密碼輸入框/驗(yàn)證碼輸入框

 更新時(shí)間:2023年08月30日 15:11:19   作者:前端61  
這篇文章主要為大家詳細(xì)介紹了如何利用vue實(shí)現(xiàn)密碼輸入框或驗(yàn)證碼輸入框的效果,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以參考一下

1.效果預(yù)覽

2.實(shí)現(xiàn)思路

制作6個(gè)小的正方形div

用一個(gè)input覆蓋在6個(gè)div上

給input設(shè)置透明(隱藏掉input)

3.源碼

html

<div class="input-box flexbox">
	<div class="code-item" :class="codeValue.length == 0 && inputFocus ? 'code-item-active' : ''">{{codeValue[0]}}</div>
	<div class="code-item" :class="codeValue.length == 1 && inputFocus ? 'code-item-active' : ''">{{codeValue[1]}}</div>
	<div class="code-item" :class="codeValue.length == 2 && inputFocus ? 'code-item-active' : ''">{{codeValue[2]}}</div>
    <div class="code-item" :class="codeValue.length == 3 && inputFocus ? 'code-item-active' : ''">{{codeValue[3]}}</div>
    <div class="code-item" :class="codeValue.length == 4 && inputFocus ? 'code-item-active' : ''">{{codeValue[4]}}</div>
    <div class="code-item" :class="codeValue.length >= 5 && inputFocus ? 'code-item-active' : ''">{{codeValue[5]}}</div>
    <el-input class="input-code"
      :value="codeValue"
      :maxlength="6"
      @blur="codeInputBlur"
      @focus="codeInputFocus"
      @input="codeInputChange">
    </el-input>
  </div>

css

  .input-box {
    margin-top: 20px;
    position: relative;
  }
  .input-code {
    position: absolute;
  }
  .code-item {
    width: 50px;
    height: 50px;
    text-align: center;
    line-height: 50px;
    border: 1px solid #f0f0f0;
    margin-right: 10px;
  }
  .code-item-active {
    border: 1px solid #F23026;
    box-sizing: border-box;
  }
  // 隱藏input
  .input-box {
    .el-input__inner {
      width: 362px;
      height: 50px;
      background-color: transparent;
      border: none;
      color: transparent;
    }
  }

js

data() {
    return {
      codeValue: '',
      inputFocus: false,
      sendCodeFlag: false,
      codeTime: 59,
    };
  },
  methods: {
    // 發(fā)送驗(yàn)證碼
    sendCode() {
      this.codeTime = 59;
      this.sendCodeFlag = true;
      const timer = setInterval(() => {
        this.codeTime -= 1;
        if (this.codeTime <= 0) {
          this.sendCodeFlag = false;
          clearInterval(timer);
        }
      }, 1000);
    },
    // 驗(yàn)證碼輸入框
    codeInputChange(e) {
      if (e) {
      // 判斷輸入內(nèi)容是否為數(shù)字
        if ((/^\+?[0-9][0-9]*$/).test(e)) {
          this.codeValue = e;
        }
      } else {
        this.codeValue = '';
      }
    },
    // 驗(yàn)證碼輸入框失去焦點(diǎn)
    codeInputBlur() {
      this.inputFocus = false;
    },
    // 驗(yàn)證碼輸入框獲取到焦點(diǎn)
    codeInputFocus() {
      this.inputFocus = true;
    },
  },

到此這篇關(guān)于利用vue實(shí)現(xiàn)密碼輸入框/驗(yàn)證碼輸入框的文章就介紹到這了,更多相關(guān)vue輸入框內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue3界面使用router及使用watch監(jiān)聽router的改變

    vue3界面使用router及使用watch監(jiān)聽router的改變

    vue2中使用router非常簡單,但是vue3中略微有些改變,通過本文講解下他的改變,對(duì)vue3?watch監(jiān)聽router相關(guān)知識(shí)感興趣的朋友一起看看吧
    2022-11-11
  • 通過html文件來使用Vue的單文件組件形式詳解

    通過html文件來使用Vue的單文件組件形式詳解

    這篇文章主要介紹了通過html文件來使用Vue的單文件組件形式詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • vue 將頁面公用的頭部組件化的方法

    vue 將頁面公用的頭部組件化的方法

    本篇文章主要介紹了vue 將頁面公用的頭部組件化的方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-12-12
  • vue中關(guān)閉eslint的方法分析

    vue中關(guān)閉eslint的方法分析

    這篇文章給大家講述了vue中關(guān)閉eslint的方法內(nèi)容,有需要的讀者們可以參考學(xué)習(xí)下。
    2018-08-08
  • 教你在vue項(xiàng)目中使用svg圖標(biāo)的方法

    教你在vue項(xiàng)目中使用svg圖標(biāo)的方法

    本文給大家介紹了在vue項(xiàng)目中使用svg圖標(biāo)的方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2022-04-04
  • Vue.js實(shí)現(xiàn)微信過渡動(dòng)畫左右切換效果

    Vue.js實(shí)現(xiàn)微信過渡動(dòng)畫左右切換效果

    這篇文章主要給大家介紹了利用Vue.js仿微信過渡動(dòng)畫左右切換效果的相關(guān)資料,需要用到的技術(shù)棧是Vue+Vuex。文中通過示例代碼介紹的非常詳細(xì),對(duì)大家具一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。
    2017-06-06
  • Vue中設(shè)置el-select的高度不生效問題及解決方案

    Vue中設(shè)置el-select的高度不生效問題及解決方案

    文章介紹了如何使用ElementUI框架中的el-select組件,并解決設(shè)置其高度不生效的問題,在Vue2.x中,使用/deep/關(guān)鍵字可以穿透組件作用域修改樣式;在Vue2.6+到Vue3初期,推薦使用::v-deep關(guān)鍵字;在最新的Vue3和構(gòu)建工具中,推薦使用:deep()偽類來代替::v-deep
    2025-01-01
  • Vue項(xiàng)目打包部署到iis服務(wù)器的配置方法

    Vue項(xiàng)目打包部署到iis服務(wù)器的配置方法

    這篇文章主要介紹了Vue項(xiàng)目打包部署到iis服務(wù)器的配置方法,文中通過代碼示例給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2019-10-10
  • 如何獲取vue單文件自身源碼路徑

    如何獲取vue單文件自身源碼路徑

    這篇文章主要介紹了如何獲取vue單文件自身源碼路徑,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-05-05
  • 基于Vue實(shí)現(xiàn)卡片無限滾動(dòng)動(dòng)畫

    基于Vue實(shí)現(xiàn)卡片無限滾動(dòng)動(dòng)畫

    這篇文章主要為大家詳細(xì)介紹了如何利用Vue制作出卡片無限滾動(dòng)動(dòng)畫,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)有一定幫助,需要的可以參考一下
    2022-05-05

最新評(píng)論