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

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

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

參考:vue下的密碼輸入框

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

1.效果預(yù)覽

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

制作6個小的正方形div

用一個input覆蓋在6個div上

給input設(shè)置透明(透明掉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) {
    // // 判斷輸入內(nèi)容是否為數(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);
}
// 密碼輸入框失去焦點(diǎn)
const codeInputBlur = () => {
  inputFocus.value = false
}
// 密碼輸入框獲取到焦點(diǎn)
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>

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

相關(guān)文章

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

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

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

    Vue-CLI3.x 自動部署項(xiàng)目至服務(wù)器的方法步驟

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

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

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

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

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

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

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

    詳解Vue如何使用xlsx庫導(dǎo)出Excel文件

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

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

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

    淺談Vue知識系列-axios

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

    詳解Vue計算屬性原理

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

    vue如何在項(xiàng)目中調(diào)用騰訊云的滑動驗(yàn)證碼

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

最新評論