vue車(chē)牌輸入組件

介紹

  • vue-license-plate是一款基于vue的車(chē)牌號(hào)輸入控件。

項(xiàng)目中使用

  • 下載
//vue2
npm install vue-license-plate

//vue3
npm install vue3-license-plate
  • 在main.js中加入
//vue2
import LicensePlate from 'vue-license-plate'
import 'vue-license-plate/lib/licensePlate.css'
Vue.use(LicensePlate);

//vue3
import LicensePlate from 'vue3-license-plate'
import 'vue3-license-plate/lib/licensePlate.css'

createApp(App).use(LicensePlate).mount('#app')
  • 在需要的頁(yè)面中使用
licensePlate: "川A00001"
<LicensePlate v-model="licensePlate" @change="change"></LicensePlate>
change(val){
    console.log(val.array)  //數(shù)組形式
    console.log(val.value)  //字符串形式
    console.log(val.pass)     //是否驗(yàn)證通過(guò)
}
  • 自定義車(chē)牌展示
<LicensePlate :borderRadius="6"
    @change="changeVal"
    v-model="licensePlate"
    :autoShow="false">
    <div class="custom">{{ licensePlate }}</div>
</LicensePlate>
//自定義時(shí) borderColor borderActiveColor borderWidth borderRadius  fontColor fontSize 無(wú)效
//自定義時(shí)點(diǎn)擊事件根據(jù)當(dāng)前長(zhǎng)度計(jì)算,即默認(rèn)選中最后一位
  • 展示如下


    s1.png

API

Props

名字 類(lèi)型 默認(rèn)值 說(shuō)明
borderColor String #79aef3 輸入框邊框顏色
borderActiveColor String #330aec 輸入框選中的邊框顏色
borderWidth Number 1 邊框?qū)挾?/td>
borderRadius Number 6 邊框圓角
fontColor String #333333 文字顏色
fontSize Number 16 文字大小

Events

名字 說(shuō)明 回調(diào)參數(shù)
@change 輸入改變時(shí)觸發(fā) {array:[],value:string,pass:false}

完整代碼

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容