<el-form ref="ruleFormRef" :model="ruleForm" status-icon :rules="rules" label-width="120px" class="demo-ruleForm" > <br /> <br /> <el-form-item label="//前缀" prop="checkPass"> <el-input v-model="ruleForm.checkPass" type="text" autocomplete="off" placeholder="" /> </el-form-item> </el-form>
const ruleForm = reactive({ checkPass: '', }); const rules = reactive<FormRules<typeof ruleForm>>({ checkPass: [{ validator: validatePass2, trigger: 'blur' }], }); const validatePass2 = (rule: any, value: any, callback: any) => { if (value === '') { callback(new Error('输入内容')); } else { callback(); } };