亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

1.效果預覽

2.實現(xiàn)思路

制作6個小的正方形div

用一個input覆蓋在6個div上

給input設置透明(隱藏掉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ā)送驗證碼
    sendCode() {
      this.codeTime = 59;
      this.sendCodeFlag = true;
      const timer = setInterval(() => {
        this.codeTime -= 1;
        if (this.codeTime <= 0) {
          this.sendCodeFlag = false;
          clearInterval(timer);
        }
      }, 1000);
    },
    // 驗證碼輸入框
    codeInputChange(e) {
      if (e) {
      // 判斷輸入內(nèi)容是否為數(shù)字
        if ((/^\+?[0-9][0-9]*$/).test(e)) {
          this.codeValue = e;
        }
      } else {
        this.codeValue = '';
      }
    },
    // 驗證碼輸入框失去焦點
    codeInputBlur() {
      this.inputFocus = false;
    },
    // 驗證碼輸入框獲取到焦點
    codeInputFocus() {
      this.inputFocus = true;
    },
  },

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

相關(guān)文章

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

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

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

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

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

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

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

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

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

    教你在vue項目中使用svg圖標的方法

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

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

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

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

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

    Vue項目打包部署到iis服務器的配置方法

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

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

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

    基于Vue實現(xiàn)卡片無限滾動動畫

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

最新評論