<template>
<van-cell-group>
<van-field label="姓名" name="name" readonly required v-model="cellData.name"
:rules="[{ required: true, message: '姓名不能为空!' }]">
<template v-slot:input>
<input :value="cellData.name" @input="handleInput">
</template>
</van-field>
</van-cell-group>
</template>
<script>
const cellData = ref({
id:null,
name:''
})
const handleInput = (event) => {
// 实时更新name的值
cellData.value.name = event.target.value;
};
</scrpt>
vue3 js 实时校验input框中的值 @input监听
于 2024-02-02 16:08:28 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)