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 | 格框外观形态 | String | radius | square | round | underline | 'radius' |
| disabled | 是否禁用输入只读 | Boolean | true | false | false |
| autoFocus | 是否自动弹起车牌号键盘 | Boolean | true | false | false |
| keyboardTitle | 弹出的虚拟键盘标题 | String | - | '请输入车牌号码' |
事件说明 (Events)
| 事件名 | 说明 | 回调参数 |
|---|---|---|
| change | 每次输入或删除字符改变时触发 | (value: String) |
| finish | 当车牌号录入达到 7 位或 8 位完成时触发 | (value: String) |
| update:modelValue | 双向绑定更改变 | (value: String) |