fix(component): fix: 修复rule validator类型默认为string,导致 radio 等组件在 setFormValues 时,如果值不是string类型,提示校验错误
parent
97de2d680b
commit
781f7c9cd1
|
@ -200,9 +200,6 @@ export default defineComponent({
|
||||||
rule.required = false
|
rule.required = false
|
||||||
|
|
||||||
if (component) {
|
if (component) {
|
||||||
if (!Reflect.has(rule, 'type'))
|
|
||||||
rule.type = component === 'InputNumber' ? 'number' : 'string'
|
|
||||||
|
|
||||||
rule.message = rule.message || defaultMsg
|
rule.message = rule.message || defaultMsg
|
||||||
|
|
||||||
if (component.includes('Input') || component.includes('Textarea'))
|
if (component.includes('Input') || component.includes('Textarea'))
|
||||||
|
|
|
@ -36,6 +36,9 @@ function genType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setComponentRuleType(rule: Rule, component: ComponentType, valueFormat: string) {
|
export function setComponentRuleType(rule: Rule, component: ComponentType, valueFormat: string) {
|
||||||
|
if (Reflect.has(rule, 'type'))
|
||||||
|
return
|
||||||
|
|
||||||
if (['DatePicker', 'MonthPicker', 'WeekPicker', 'TimePicker'].includes(component))
|
if (['DatePicker', 'MonthPicker', 'WeekPicker', 'TimePicker'].includes(component))
|
||||||
rule.type = valueFormat ? 'string' : 'object'
|
rule.type = valueFormat ? 'string' : 'object'
|
||||||
else if (['RangePicker', 'Upload', 'CheckboxGroup', 'TimePicker'].includes(component))
|
else if (['RangePicker', 'Upload', 'CheckboxGroup', 'TimePicker'].includes(component))
|
||||||
|
|
Loading…
Reference in New Issue