-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Description
Existing Component
是
Component Name
el-form-item
Description
When using the form component,need to display the error message for validation in other ways,However, it is found that the validateMessage cannot be obtained within the component
validate(trigger, callback = noop) {
this.validateDisabled = false;
const rules = this.getFilteredRule(trigger);
if ((!rules || rules.length === 0) && this.required === undefined) {
callback();
return true;
}
this.validateState = 'validating';
const descriptor = {};
if (rules && rules.length > 0) {
rules.forEach(rule => {
delete rule.trigger;
});
}
descriptor[this.prop] = rules;
const validator = new AsyncValidator(descriptor);
const model = {};
model[this.prop] = this.fieldValue;
validator.validate(model, { firstFields: true }, (errors, invalidFields) => {
this.validateState = !errors ? 'success' : 'error';
this.validateMessage = errors ? errors[0].message : '';
callback(this.validateMessage, invalidFields);
this.elForm && this.elForm.$emit('validate', this.prop, !errors);
});
}
Even though he's close to me,But you can't get him.
My idea is to put him here
this.elForm && this.elForm.$emit('validate', this.prop, !errors,this.validateMessage);
back at the farm,how do I get 'validateMessage'?