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

vue3實現(xiàn)密碼輸入框效果的示例代碼

 更新時間:2023年08月30日 15:12:40   作者:來福福是小可愛!  
這篇文章主要為大家詳細介紹了如何利用vue3實現(xiàn)6位的密碼輸入框效果,文中的示例代碼簡潔易懂,感興趣的小伙伴可以跟隨小編一起學習一下

參考:vue下的密碼輸入框

注意:這是個半成品,有些問題(input輸入框加了文字間距l(xiāng)etter-spaceing,會導致輸入到第6位的時候會往后竄出來一個空白框、光標位置頁會在數(shù)字前面),建議不采用下面這種方式,用另外的(畫六個input框更方便)

1.效果預覽

2.實現(xiàn)思路

制作6個小的正方形div

用一個input覆蓋在6個div上

給input設置透明(透明掉input)

3.源碼

html

          <div class="footerTextStyle">請輸入6位數(shù)支付密碼</div>
          <div class="input-box">
            <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 code-item-last" :class="codeValue?.length >= 5 && inputFocus ? 'code-item-active' : ''">{{ codeValue[5]
            }}
            </div>
            <a-input class="input-code" v-model:value="codeValue" type="" @blur="codeInputBlur"
              @focus="codeInputFocus" @input="codeInputChange" maxlength="6" />
          </div>

js

// 輸入的6位密碼
const codeValue = ref([])
const inputFocus = ref(false)
// 密碼輸入框
const codeInputChange = (e : any) => {
  console.log('喵喵喵:', e.data);
  if (e) {
    // // 判斷輸入內容是否為數(shù)字
    // if ((/^\+?[0-9][0-9]*$/).test(e)) {
    //   codeValue.value = e.data
    // }
    Array.from(codeValue.value).push(e.data)
  } else {
    codeValue.value = []
  }
  console.log('咩咩:', codeValue.value);
}
// 密碼輸入框失去焦點
const codeInputBlur = () => {
  inputFocus.value = false
}
// 密碼輸入框獲取到焦點
const codeInputFocus = () => {
  inputFocus.value = true
}

css

<style lang="scss" scoped>
// 密碼輸入框
.input-box {
  position: relative;
  margin: 4px 0px 20px 0px;
  display: flex;
  width: 290px;
  height: 48px;
  background-color: transparent;
  border: none;
  color: transparent;
}
// 透明input
.input-code {
  position: absolute;
  width: 290px;
  height: 48px;
  background-color: transparent;
  border: none;
  letter-spacing: 40px;
  padding: 0px 20px;
}
.code-item {
  width: 48px;
  height: 48px;
  text-align: center;
  line-height: 48px;
  border: 1px solid rgba(51,51,51,0.20);
  border-right: none;
  border-radius: 5px;
}
.code-item-last{
  border-right: 1px solid rgba(51,51,51,0.20);
}
.code-item-active {
  border: 1px solid #F23026;
  box-sizing: border-box;
}
</style>

到此這篇關于vue3實現(xiàn)密碼輸入框效果的示例代碼的文章就介紹到這了,更多相關vue3密碼輸入框內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • vue3采用xlsx庫實現(xiàn)本地上傳excel文件功能

    vue3采用xlsx庫實現(xiàn)本地上傳excel文件功能

    這篇文章主要為大家詳細介紹了vue3如何采用xlsx庫實現(xiàn)本地上傳excel文件功能,并且前端解析為Json數(shù)據(jù),感興趣的小伙伴可以了解一下
    2025-02-02
  • Vue-CLI3.x 自動部署項目至服務器的方法步驟

    Vue-CLI3.x 自動部署項目至服務器的方法步驟

    本教程講解的是 Vue-CLI 3.x 腳手架搭建的vue項目, 利用scp2自動化部署到靜態(tài)文件服務器 Nginx,感興趣的可以了解一下
    2021-11-11
  • vite/Vuecli配置proxy代理解決跨域問題

    vite/Vuecli配置proxy代理解決跨域問題

    這篇文章主要介紹了vite/Vuecli配置proxy代理解決跨域問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • vue組件講解(is屬性的用法)模板標簽替換操作

    vue組件講解(is屬性的用法)模板標簽替換操作

    這篇文章主要介紹了vue組件講解(is屬性的用法)模板標簽替換操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • VUE3基于vite封裝條形碼和二維碼組件的詳細過程

    VUE3基于vite封裝條形碼和二維碼組件的詳細過程

    基礎組件開發(fā)是項目業(yè)務開發(fā)的基石, 本文主要介紹了通過vue3的vite腳手架快速搭建項目, 開發(fā)條形碼和二維碼組件的過程,感興趣的朋友跟隨小編一起看看吧
    2023-08-08
  • 詳解Vue如何使用xlsx庫導出Excel文件

    詳解Vue如何使用xlsx庫導出Excel文件

    第三方庫xlsx提供了強大的功能來處理Excel文件,它可以簡化導出Excel文件這個過程,本文將為大家詳細介紹一下它的具體使用,需要的小伙伴可以了解下
    2025-01-01
  • vue前端如何向后端傳遞參數(shù)

    vue前端如何向后端傳遞參數(shù)

    這篇文章主要介紹了vue前端如何向后端傳遞參數(shù),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • 淺談Vue知識系列-axios

    淺談Vue知識系列-axios

    這篇文章主要介紹了淺談Vue知識系列-axios,本文章內容詳細,具有很好的參考價值,希望對大家有所幫助,需要的朋友可以參考下<BR>
    2023-01-01
  • 詳解Vue計算屬性原理

    詳解Vue計算屬性原理

    計算屬性是Vue中比較好用的API,開發(fā)者可以利用計算屬將復雜的計算進行緩存,同時基于它的響應式特性,我們無需關注數(shù)據(jù)更新問題,但需要注意的是,計算屬性是惰性求值的,本文將詳細介紹計算屬性的實現(xiàn)原理,需要的朋友可以參考下
    2023-05-05
  • vue如何在項目中調用騰訊云的滑動驗證碼

    vue如何在項目中調用騰訊云的滑動驗證碼

    這篇文章主要介紹了vue如何在項目中調用騰訊云的滑動驗證碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-07-07

最新評論