Skip to content

CarInput 车牌号输入框

专用于汽车车牌号码录入的独立组件,包含 8 位分割格框(支持新能源汽车 +1 位插槽与绿色徽标),自动联动弹出车牌号专用键盘。


代码示例

1. 基础车牌号输入

使用 v-model 绑定输入的车牌号码。输入完成后自动触发 @finish 事件。

vue
<template>
  <mu-car-input v-model="carNumber" @finish="handleFinish" />
</template>

<script setup>
import { ref } from 'vue'
const carNumber = ref('京A88888')
const handleFinish = (val) => {
  console.log('车牌号录入成功:', val)
}
</script>

2. 矩形与下划线形态

通过 shape 设置格框外观形态,支持 radius (默认圆角)、square (微直角) 及 underline (极简下划线)。

vue
<template>
  <!-- 微直角 -->
  <mu-car-input v-model="car1" shape="square" />

  <!-- 极简下划线 -->
  <mu-car-input v-model="car2" shape="underline" />
</template>

<script setup>
import { ref } from 'vue'
const car1 = ref('')
const car2 = ref('')
</script>

3. 禁用状态 (Disabled)

设置 disabled 开启只读防护。

vue
<template>
  <mu-car-input model-value="粤B88888" disabled />
</template>

API 属性说明 (Props)

参数名说明类型可选值默认值
v-model当前已输入的车牌号码字符串String-''
shape格框外观形态Stringradius | square | round | underline'radius'
disabled是否禁用输入只读Booleantrue | falsefalse
autoFocus是否自动弹起车牌号键盘Booleantrue | falsefalse
keyboardTitle弹出的虚拟键盘标题String-'请输入车牌号码'

事件说明 (Events)

事件名说明回调参数
change每次输入或删除字符改变时触发(value: String)
finish当车牌号录入达到 7 位或 8 位完成时触发(value: String)
update:modelValue双向绑定更改变(value: String)

基于 MIT 协议开源发行

H5 模拟器 (car-input)☀️🔄