使用Vue實(shí)現(xiàn)簡(jiǎn)易的車牌輸入鍵盤
效果圖如下:
代碼如下:
<template> <div> <div class="carNoBoxInput"> <div style="padding: 6px;border: 2px solid #fff;border-radius: 6px;margin: 6px 3px 6px 6px;"> <input class="inputBox" :value="licensePlateUnit[0]" @click="licensePlateDoor = true"/> <input class="inputBox" :value="licensePlateUnit[1]" @click="licensePlateDoor = true"/> <span class="dot"></span> <input class="inputBox" :value="licensePlateUnit[2]" @click="licensePlateDoor = true"/> <input class="inputBox" :value="licensePlateUnit[3]" @click="licensePlateDoor = true"/> <input class="inputBox" :value="licensePlateUnit[4]" @click="licensePlateDoor = true"/> <input class="inputBox" :value="licensePlateUnit[5]" @click="licensePlateDoor = true"/> <input class="inputBox" :value="licensePlateUnit[6]" @click="licensePlateDoor = true"/> <input v-if="7 === licensePlateUnit.length - 1" class="inputBox" :class="7 === licensePlateUnit.length - 1 ? 'inputBoxActive' : 'inputBox'" :value="licensePlateUnit[7]"/> <img v-if="7 !== licensePlateUnit.length - 1" src="../assets/newEnergy.png" style="height: 36px;width: 36px;" alt="新能源"/> </div> </div> <div v-if="licensePlateDoor"> <div v-if="licensePlateUnit.length < 1" class="carNoBox"> <span class="carNo" v-for="item in columns" :key="item" @click="pickOn(item)"> {{item}} </span> <span class="delBt" @click="delCarNo">X</span> </div> <div v-if="licensePlateUnit.length >= 1" class="carNoBox"> <span class="carNo" v-for="item in numberColumns" :key="item" @click="pickOn(item)"> {{item}} </span> <div style="display: flex;align-items: center"> <span class="delBt" @click="delCarNo">X</span> <span class="delBt" style="margin-left: 6px;width: 42px" @click="confirm">確認(rèn)</span> </div> </div> </div> </div> </template> <script> export default { data() { return { licensePlateDoor: false, activeIndex: 0, licensePlateUnit: [], columns: [//省縮寫選擇 '京', '滬', '鄂', '湘', '川', '渝', '粵', '閩', '晉', '黑', '津', '浙', '豫', '贛', '貴', '青', '瓊', '寧', '吉', '蒙', '冀', '蘇', '皖', '桂', '云', '陜', '甘', '藏', '新', '遼', '魯'], numberColumns: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0','Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '港','澳','學(xué)','領(lǐng)','警' ], } }, methods: { pickOn(value) { this.licensePlateDoor = true; if (this.licensePlateUnit.length <= 7) { this.licensePlateUnit.push(value) } }, delCarNo() { this.licensePlateUnit.pop(); }, confirm() { if(this.licensePlateUnit.length >= 7) { console.log("車牌是:"+this.licensePlateUnit.join('')); this.licensePlateDoor = false; } }, } } </script> <style scoped> .carNo { border-radius: 6px; background: #fff; font-weight: bold; font-size: 20px; height: 28px; width:28px; margin: 6px; padding: 12px; cursor: pointer; } .inputBox { color: white; height: 30px; line-height: 30px; width: 30px; font-size: 28px; text-align: center; background-color: transparent; border: none; outline: none; caret-color: rgba(0, 0, 0, 0) } input:focus { border-bottom: 3px solid #fff; transition: all 0.5s; } .dot { margin-bottom: 6px; background-color: #fff; height: 6px; width: 6px; border-radius: 50%; display: inline-block } .delBt { background: #ACB3BB; border-radius: 6px; display: inline-block; font-weight: bold; font-size: 20px; height: 28px; width:28px; margin: 6px; padding: 12px; cursor: pointer; } .carNoBoxInput { display: flex; width: 310px; align-items: center; //height: 80px; border-radius: 8px; margin: 12px 0; background: #2D66D8; } .carNoBox { background: #D0D5D9; position: relative; width: 600px; border-radius: 6px; display: flex; flex-wrap: wrap; justify-items: center; align-items: center } </style>
到此這篇關(guān)于使用Vue實(shí)現(xiàn)簡(jiǎn)易的車牌輸入鍵盤的文章就介紹到這了,更多相關(guān)Vue車牌輸入鍵盤內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue實(shí)現(xiàn)echarts餅圖/柱狀圖點(diǎn)擊事件實(shí)例
echarts原生提供了相應(yīng)的API,只需要在配置好echarts之后綁定相應(yīng)的事件即可,下面這篇文章主要給大家介紹了關(guān)于vue實(shí)現(xiàn)echarts餅圖/柱狀圖點(diǎn)擊事件的相關(guān)資料,需要的朋友可以參考下2023-06-06vue通過(guò)?API?監(jiān)聽數(shù)組的變化
這篇文章主要介紹了vue通過(guò)?API?監(jiān)聽數(shù)組的變化,在?Vue?中,你可以通過(guò)監(jiān)聽數(shù)組的變化來(lái)更新界面,Vue?提供了一些特殊的語(yǔ)法以及?API?來(lái)實(shí)現(xiàn)對(duì)數(shù)組的監(jiān)聽,本文通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-05-05在Vue中使用動(dòng)態(tài)import()語(yǔ)法動(dòng)態(tài)加載組件
在Vue中,你可以使用動(dòng)態(tài)import()語(yǔ)法來(lái)動(dòng)態(tài)加載組件,動(dòng)態(tài)導(dǎo)入允許你在需要時(shí)異步加載組件,這樣可以提高應(yīng)用程序的初始加載性能,本文給大家介紹在Vue中使用動(dòng)態(tài)import()語(yǔ)法動(dòng)態(tài)加載組件,感興趣的朋友一起看看吧2023-11-11快速解決Vue項(xiàng)目在IE瀏覽器中顯示空白的問(wèn)題
今天小編就為大家分享一篇快速解決Vue項(xiàng)目在IE瀏覽器中顯示空白的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09vue頁(yè)面監(jiān)聽是否置為后臺(tái)或可見狀態(tài)問(wèn)題
這篇文章主要介紹了vue頁(yè)面監(jiān)聽是否置為后臺(tái)或可見狀態(tài)問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10Vue3+Canvas實(shí)現(xiàn)簡(jiǎn)易的貪吃蛇游戲
貪吃蛇作為一個(gè)經(jīng)典的小游戲,是很多人兒時(shí)的記憶,當(dāng)時(shí)的掌機(jī)、諾基亞手機(jī)里面都有它的身影。本文將用Vue3?Canvas來(lái)復(fù)刻一下這款游戲,感興趣的可以了解一下2022-07-07