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

基于vue+h5實(shí)現(xiàn)車(chē)牌號(hào)輸入框功能(demo)

 更新時(shí)間:2025年03月27日 11:22:09   作者:鵬仔工作室  
最近開(kāi)發(fā)項(xiàng)目是學(xué)校校內(nèi)車(chē)輛超速方面的統(tǒng)計(jì)檢測(cè)方面的系統(tǒng),在開(kāi)發(fā)過(guò)程中發(fā)現(xiàn)有個(gè)小功能,就是用戶移動(dòng)端添加車(chē)牌號(hào),剛開(kāi)始想著輸入框,提交時(shí)正則效驗(yàn)一下格式,最后感覺(jué)不方便,所以就簡(jiǎn)單自己手寫(xiě)了一個(gè)H5車(chē)牌號(hào)軟鍵盤(pán),對(duì)vue車(chē)牌號(hào)輸入框?qū)崿F(xiàn)代碼感興趣的朋友一起看看吧

哈嘍,大家好,最近鵬仔開(kāi)發(fā)的項(xiàng)目是學(xué)校校內(nèi)車(chē)輛超速方面的統(tǒng)計(jì)檢測(cè)方面的系統(tǒng),在開(kāi)發(fā)過(guò)程中發(fā)現(xiàn)有個(gè)小功能,就是用戶移動(dòng)端添加車(chē)牌號(hào),剛開(kāi)始想著就一個(gè)輸入框,提交時(shí)正則效驗(yàn)一下格式就行,最后感覺(jué)不是很方便,所以就簡(jiǎn)單自己手寫(xiě)了一個(gè)H5車(chē)牌號(hào)軟鍵盤(pán),由于每天工作比較忙,就沒(méi)封裝成插件了,趁著晚上空閑,給大家整理一下demo,復(fù)制即可使用,或者自行封裝一個(gè)組件調(diào)用也可以(代碼中一些寫(xiě)法可能過(guò)于粗糙,時(shí)間有限,任務(wù)多,就粗糙寫(xiě)一下吧,反正功能是實(shí)現(xiàn)了)。

功能如上圖所示,支持 8位電車(chē)車(chē)牌和7位油車(chē)車(chē)牌。

第一位是 省份,用戶點(diǎn)擊就會(huì)彈出省份軟鍵盤(pán);

第二位是 字母,用戶點(diǎn)擊只能輸入字母;

第三、四、五、六位是字母和數(shù)字,不包含O;

第七位是 數(shù)字、字母、或者學(xué)、警之類(lèi)漢字;

第八位是 電車(chē)選項(xiàng)。

用戶點(diǎn)擊軟鍵盤(pán)對(duì)應(yīng)的按鍵時(shí)會(huì)高亮,這個(gè)是后期加的,所以上圖中沒(méi)有展示出來(lái)。

鵬仔的移動(dòng)端是rem布局,根元素是26.67vw,如果你使用,可自行根據(jù)自己的項(xiàng)目將css中所有的單位變化一下。

body,div,p,ul,ol,li,dl,dt,dd,table,tr,td,form,hr,h1,h2,h3,h4,h5,h6,fieldset,img,input {margin:0;padding:0}
body,html {width:100%;height:100%;font-size: 26.67vw;}

完整代碼如下

<template>
  <div class="layer">
    <!-- content -->
    <div class="content-layer">
      <div class="my-car-layer">
        <!-- 添加車(chē)輛 -->
        <div class="my-car-layer-add" @click="addShow = true">
          <div class="add-text">
            <p>添加車(chē)輛</p>
          </div>
        </div>
      </div>
    </div>
    <!-- 添加車(chē)輛彈窗 -->
    <div class="shade-layer" v-if="addShow" @click="keyboardShow = false">
      <div class="add-content">
        <div class="add-header">
          <p>車(chē)輛信息</p>
          <span @click="addShow = false">關(guān)閉</span>
        </div>
        <div class="form-list">
          <p>車(chē)牌號(hào):</p>
          <div class="car-num-input">
            <div v-for="(item,index) in carNumList" :key="index" @click.stop="selectCarNum(index)" :class="(carIndex == index ? 'active' : '') + ' ' + (item ? 'status-key' : '')">
              {{ index == 0 && !item ? '省' : index == carNumList.length-1 && !item ? '新能源' : item }}
            </div>
          </div>
        </div>
        <button class="submit-btn" @click="carSubmitBtn()" v-points>提交</button>
      </div>
      <!-- 車(chē)牌鍵盤(pán) -->
      <div class="keyboard-layer" v-if="keyboardShow" @click.stop="">
        <div class="keyboard-header">
          <span @click="keyboardShow = false">完成</span>
        </div>
        <!-- 省份鍵盤(pán) -->
        <div class="province-layer" v-if="carIndex == '0'">
          <span v-for="(item,index) in provinceList" :key="index" @click="keyboardBtn(item)" :class="activeKey == item ? 'active-hover' : ''">{{ item == 'del' ? '刪除' : item }}</span>
        </div>
        <!-- 數(shù)字字母鍵盤(pán) -->
        <div class="keyboard-item" v-if="carIndex != '0'">
          <div v-if="carIndex != '1'">
            <span v-for="(item,index) in keyboardList[0]" :key="index" @click="keyboardBtn(item)" :class="activeKey == item ? 'active-hover' : ''">{{ item }}</span>
          </div>
          <div>
            <span v-for="(item,index) in keyboardList[1]" :key="index" @click="keyboardBtn(item)" :class="((item == 'O' && carIndex != '1') ? 'no-btn' : '') + ' ' + (activeKey == item ? 'active-hover' : '')">{{ item }}</span>
          </div>
          <div>
            <span v-for="(item,index) in keyboardList[2]" :key="index" @click="keyboardBtn(item)" :class="activeKey == item ? 'active-hover' : ''">{{ item }}</span>
          </div>
          <div>
            <span v-for="(item,index) in keyboardList[3]" :key="index" @click="keyboardBtn(item)" :class="activeKey == item ? 'active-hover' : ''">{{ item == 'del' ? '刪除' : item }}</span>
          </div>
          <div v-if="carIndex == carNumList.length-2">
            <span v-for="(item,index) in keyboardList[4]" :key="index" @click="keyboardBtn(item)" :class="activeKey == item ? 'active-hover' : ''">{{ item }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "car",
  mixins: [],
  components: {},
  data() {
    return {
      addShow: false, // 添加車(chē)輛彈窗顯示隱藏
      formData: {
        carNumber: ''
      },
      carNumList: ['','','','','','','',''], // 車(chē)牌號(hào)數(shù)組
      activeKey: '', // 鍵盤(pán)按鍵選中激活
      timeoutId: null, // 定時(shí)器ID
      carIndex: null, // 車(chē)牌號(hào)輸入光標(biāo)索引
      keyboardShow: false, // 鍵盤(pán)顯示/隱藏
      provinceList: [
        '京', '津', '滬', '渝', '冀', '豫', '云', '遼', '黑', '湘',
        '皖', '魯', '新', '蘇', '浙', '贛', '鄂', '桂', '甘', '晉',
        '蒙', '陜', '吉', '閩', '貴', '粵', '青', '藏', '川', '寧',
        '瓊', '使', '領(lǐng)', '學(xué)', '警', '掛', 'del'
      ],
      keyboardList: [
        ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
        ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'O', 'P'],
        ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L'],
        ['Z', 'X', 'C', 'V', 'B', 'N', 'M', 'del'],
        ['學(xué)','警','港','澳']
      ]
    };
  },
  mounted() {
  },
  methods: {
    // 添加車(chē)輛
    carSubmitBtn(){
      this.formData.carNumber = '';
      for(let i in this.carNumList){
        if(this.carNumList[i] == '' && i != this.carNumList.length-1){
          console.log('請(qǐng)輸入完整車(chē)牌號(hào)');
          return;
        }
        this.formData.carNumber += this.carNumList[i];
      }
      console.log(this.formData.carNumber)
    },
    // 點(diǎn)擊車(chē)牌號(hào)輸入
    selectCarNum(inx){
      this.carIndex = inx;
      if(!this.keyboardShow){
        this.keyboardShow = true;
      }
    },
    // 鍵盤(pán)輸入
    keyboardBtn(val){
      this.activeKey = val; // 鍵盤(pán)按鍵選中激活
      this.activeKeyBtn(); // 鍵盤(pán)按鍵激活定時(shí)器
      this.carNumList[this.carIndex] = val == 'del' ? '' : val;
      if(val == 'del' && this.carIndex > 0){
        this.carIndex--;
      }
      if(val != 'del' && this.carIndex < this.carNumList.length-1){
        this.carIndex++;
      }
      this.$forceUpdate();
    },
    // 鍵盤(pán)按鍵激活定時(shí)器
    activeKeyBtn() {
      // 清除之前的定時(shí)器
      if (this.timeoutId) clearTimeout(this.timeoutId)
      // 1秒后重置狀態(tài)
      this.timeoutId = setTimeout(() => {
        this.activeKey = '';
      }, 300)
    }
  },
  watch: {
    "addShow"(){
      // 關(guān)閉彈窗時(shí)重置
      if(!this.addShow){
        this.formData = {
          carNumber: ''
        }
        this.carIndex = ''; // 車(chē)牌號(hào)輸入光標(biāo)索引
        this.carNumList = ['','','','','','','','']; // 車(chē)牌號(hào)數(shù)組
        this.keyboardShow = false; // 車(chē)牌鍵盤(pán)隱藏
      }
    }
  },
};
</script>
<style lang="scss" scoped>
.layer {
  padding: 0.22rem 0 0.64rem;
  box-sizing: border-box;
  .content-layer {
    width: 100%;
    position: relative;
    padding: 0 0.16rem;
    box-sizing: border-box;
    .my-car-layer{
      width: 100%;
      .my-car-layer-add{
        width: 100%;
        padding: 0.14rem 0.16rem;
        box-sizing: border-box;
        border-radius: 0.08rem;
        background: #FFF;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        .add-text{
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          padding-top: 0.04rem;
          box-sizing: border-box;
          p{
            color: #2E59FD;
            font-family: "PingFang SC";
            font-size: 0.14rem;
            font-weight: 700;
            line-height: 0.2rem;
          }
        }
      }
    }
  }
  .shade-layer{
    position: fixed;
    top: 0;
    left: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,.4);
    padding: 0.16rem;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    .add-content{
      width: 100%;
      padding: 0.16rem 0.16rem 0.24rem;
      box-sizing: border-box;
      border-radius: 0.16rem;
      background: #FFF;
      .add-header{
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-bottom: 0.14rem;
        box-sizing: border-box;
        p{
          color: #000;
          font-family: "PingFang SC";
          font-size: 0.16rem;
          font-weight: 700;
          line-height: 0.22rem;
        }
        span{
          color: #0A61C5;
          font-family: "PingFang SC";
          font-size: 0.12rem;
          font-weight: 700;
          line-height: 0.24rem;
          cursor: pointer;
        }
      }
      .form-list{
        p{
          color: #6B7280;
          font-family: "PingFang SC";
          font-size: 0.14rem;
          font-weight: 500;
          line-height: 0.2rem;
        }
        input{
          display: block;
          font-size: 0.14rem;
          line-height: 0.2rem;
          width: 100%;
          border-radius: 0.08rem;
          border: none;
          background: #F5F7FA;
          padding: 0.12rem 0.16rem;
          box-sizing: border-box;
        }
        .car-num-input{
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: 0.04rem 0;
          box-sizing: border-box;
          div{
            width: 0.3rem;
            height: 0.36rem;
            background: rgba(0,0,0,.05);
            border-radius: 0.04rem;
            border: 0.01rem solid transparent;
            box-sizing: border-box;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #000;
            font-size: 0.14rem;
            line-height: 0.18rem;
            &:first-child{
              color: rgba(0,0,0,.5);
            }
            &:last-child{
              border: 0.01rem dashed rgba(27, 171, 80, 0.8);
              color: rgba(0,0,0,.5);
              font-size: 0.08rem;
            }
          }
          .active{
            border: 0.01rem solid rgba(48, 112, 255, 0.8)!important;
          }
          .status-key{
            color: #000!important;
            font-size: 0.14rem!important;
            line-height: 0.18rem!important;
          }
        }
      }
      .submit-btn{
        display: block;
        width: 100%;
        border: none;
        padding: 0.06rem 0.1rem;
        box-sizing: border-box;
        border-radius: 0.52rem;
        background: linear-gradient(90deg, #0FA6F6 1.1%, #198CFE 99.99%);
        color: #FFF;
        text-align: center;
        font-family: "PingFang SC";
        font-size: 0.16rem;
        font-weight: 700;
        line-height: 0.24rem;
        margin-top: 0.24rem;
      }
    }
    .keyboard-layer{
      width: 100%;
      background: #D0D5DC;
      padding: 0.08rem 0.04rem 0.16rem;
      box-sizing: border-box;
      position: absolute;
      bottom: 0;
      left: 0;
      .keyboard-header{
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 0 0.08rem 0.08rem;
        box-sizing: border-box;
        span{
          color: #2E59FD;
          font-family: "PingFang SC";
          font-size: 0.14rem;
          font-weight: 700;
          line-height: 0.28rem;
          cursor: pointer;
        }
      }
      .province-layer{
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-wrap: wrap;
        span{
          color: #000;
          font-size: 0.14rem;
          line-height: 0.28rem;
          background: #fff;
          border-radius: 0.06rem;
          padding: 0.06rem 0.08rem;
          box-sizing: border-box;
          margin: 0.02rem;
          box-shadow: 0px 0.02rem 0.02rem 0px rgba(0, 0, 0, 0.1);
        }
      }
      .keyboard-item{
        width: 100%;
        div{
          display: flex;
          align-items: center;
          justify-content: center;
          span{
            color: #000;
            font-size: 0.14rem;
            line-height: 0.28rem;
            background: #fff;
            border-radius: 0.06rem;
            padding: 0.04rem 0.1rem;
            box-sizing: border-box;
            margin: 0.04rem;
            box-shadow: 0px 0.02rem 0.04rem 0px rgba(0, 0, 0, 0.3);
          }
        }
      }
      .no-btn{
        color: rgba(0,0,0,.4)!important;
        pointer-events: none;
      }
      .active-hover{
        background: #B3BAC7!important;
      }
    }
  }
}
</style>

原文:共享博客 sharedbk.com

vue h5實(shí)現(xiàn)車(chē)牌號(hào)輸入框

哈嘍,大家好,最近鵬仔開(kāi)發(fā)的項(xiàng)目是學(xué)校校內(nèi)車(chē)輛超速方面的統(tǒng)計(jì)檢測(cè)方面的系統(tǒng),在開(kāi)發(fā)過(guò)程中發(fā)現(xiàn)有個(gè)小功能,就是用戶移動(dòng)端添加車(chē)牌號(hào),剛開(kāi)始想著就一個(gè)輸入框,提交時(shí)正則效驗(yàn)一下格式就行,最后感覺(jué)不是很方便,所以就簡(jiǎn)單自己手寫(xiě)了一個(gè)H5車(chē)牌號(hào)軟鍵盤(pán),由于每天工作比較忙,就沒(méi)封...,共享博客-(百變鵬仔)https://www.sharedbk.com/post/284.html

到此這篇關(guān)于基于vue+h5實(shí)現(xiàn)車(chē)牌號(hào)輸入框功能的文章就介紹到這了,更多相關(guān)vue車(chē)牌號(hào)輸入框內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue element upload實(shí)現(xiàn)圖片本地預(yù)覽

    vue element upload實(shí)現(xiàn)圖片本地預(yù)覽

    這篇文章主要為大家詳細(xì)介紹了vue element upload實(shí)現(xiàn)圖片本地預(yù)覽,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-08-08
  • Vue子組件與父組件詳細(xì)解析

    Vue子組件與父組件詳細(xì)解析

    這篇文章主要介紹的是Vue子組件與父組件,什么是父組件,什么是子組件很多時(shí)候面對(duì)這個(gè)問(wèn)題我們都會(huì)有所混淆,下面文章我們就來(lái)詳細(xì)介紹,需要的朋友可以參考一下
    2021-10-10
  • Vue實(shí)現(xiàn)鎖屏功能的示例代碼

    Vue實(shí)現(xiàn)鎖屏功能的示例代碼

    這篇文章主要為大家詳細(xì)介紹了如何利用Vue實(shí)現(xiàn)簡(jiǎn)單的鎖屏功能,文中的示例代碼講解詳細(xì),具有一定的參考價(jià)值,需要的小伙伴可以了解一下
    2023-06-06
  • Vue頁(yè)面堆棧管理器詳情

    Vue頁(yè)面堆棧管理器詳情

    這篇文章主要介紹了Vue頁(yè)面堆棧管理器
    2021-10-10
  • Vue3配置bem樣式架構(gòu)的代碼詳解

    Vue3配置bem樣式架構(gòu)的代碼詳解

    BEM是一種前端命名方法論,主要是針對(duì)CSS,意思是塊(Block)、元素(Element)、修飾符(Modifier)的簡(jiǎn)寫(xiě),這種命名方法讓CSS便于統(tǒng)一團(tuán)隊(duì)開(kāi)發(fā)規(guī)范和方便維護(hù),本文給大家介紹了Vue3配置bem樣式架構(gòu),需要的朋友可以參考下
    2024-10-10
  • 詳解vue路由

    詳解vue路由

    這篇文章主要介紹了vue路由的相關(guān)資料,文中講解非常細(xì)致,幫助大家更好的理解和學(xué)習(xí)vue路由知識(shí),感興趣的朋友可以了解下
    2020-08-08
  • 在vue中使用screenfull?依賴,實(shí)現(xiàn)全屏組件方式

    在vue中使用screenfull?依賴,實(shí)現(xiàn)全屏組件方式

    這篇文章主要介紹了在vue中使用screenfull?依賴,實(shí)現(xiàn)全屏組件方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • Vue3項(xiàng)目中env文件的配置和使用指南

    Vue3項(xiàng)目中env文件的配置和使用指南

    在現(xiàn)代前端開(kāi)發(fā)中,項(xiàng)目通常需要在不同的環(huán)境中運(yùn)行,例如開(kāi)發(fā)環(huán)境、測(cè)試環(huán)境和生產(chǎn)環(huán)境,每個(gè)環(huán)境可能需要不同的配置,通過(guò)使用?.env?文件,可以方便地管理這些環(huán)境變量,避免硬編碼配置,本文給大家介紹了Vue3項(xiàng)目中env文件的配置指南,需要的朋友可以參考下
    2025-03-03
  • vue3?騰訊地圖設(shè)置簽到范圍并獲取經(jīng)緯度的實(shí)現(xiàn)代碼

    vue3?騰訊地圖設(shè)置簽到范圍并獲取經(jīng)緯度的實(shí)現(xiàn)代碼

    本文給大家介紹vue3?騰訊地圖設(shè)置簽到范圍并獲取經(jīng)緯度的實(shí)現(xiàn)代碼,本文通過(guò)示例代碼給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧
    2022-05-05
  • vue element 表頭添加斜線的實(shí)現(xiàn)代碼

    vue element 表頭添加斜線的實(shí)現(xiàn)代碼

    這篇文章主要介紹了vue element 表頭添加斜線的實(shí)現(xiàn)代碼,代碼簡(jiǎn)單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-11-11

最新評(píng)論