Skip to content

Commit

Permalink
chore: 自定义组件默认rule校验默认触发逻辑为blur
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjue666 committed Dec 13, 2023
1 parent 1296590 commit 23b6849
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/Form/src/components/FormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
dynamicRules,
required,
} = props.schema;
if (isFunction(dynamicRules)) {
return dynamicRules(unref(getValues)) as ValidationRule[];
}
Expand Down Expand Up @@ -210,7 +209,6 @@
}
return Promise.resolve();
}
const getRequired = isFunction(required) ? required(unref(getValues)) : required;
/*
Expand All @@ -220,7 +218,10 @@
*/
if (getRequired) {
if (!rules || rules.length === 0) {
rules = [{ required: getRequired, validator }];
const trigger = NO_AUTO_LINK_COMPONENTS.includes(component || 'Input')
? 'blur'
: 'change';
rules = [{ required: getRequired, validator, trigger }];
} else {
const requiredIndex: number = rules.findIndex((rule) => Reflect.has(rule, 'required'));
Expand Down

0 comments on commit 23b6849

Please sign in to comment.