diff --git a/README.md b/README.md index 025e13c..94a9ade 100644 --- a/README.md +++ b/README.md @@ -617,10 +617,12 @@ class MyField extends Component {} `EasyField` 是对`Field`的二次封装,它提供了基于浏览器原生表单控件实现的表单域快捷调用,同时也提供了统一的 `value` `onChange` `onFocus` `onBlur` 等接口方法来与其它第三方组件库对接。 -**特别提醒:`EasyField`会默认对所有的字符串输入做前后空格的过滤。如果不需要这个特性,可以通过重写`$parser`属性来关闭该功能:** +**特别提醒:`EasyField`会默认对所有的字符串输入做前后空格的过滤。如果不需要这个特性,可以通过重写`$parser`属性或者将其设置为`null`来关闭该功能:** ```javascript value} /> +// OR + ``` `EasyField`内置了一些常用的校验方法,例如: diff --git a/index.d.ts b/index.d.ts index 5b73ead..96117be 100644 --- a/index.d.ts +++ b/index.d.ts @@ -22,8 +22,7 @@ export type FieldError = { [K in keyof Validators]: DetectAny { $value: T; - $modelValue: T; - $viewValue: any, + $viewValue: any; $valid: boolean; $invalid: boolean; $dirty: boolean; @@ -167,8 +166,8 @@ export interface FieldComponentProps) => void); $validators?: Validators; $asyncValidators?: never; - $parser?: ($viewValue: any, $setViewValue: ($newViewValue: any) => any) => T; - $formatter?: ($modelValue: T, $setModelValue: ($newModelValue: T) => T) => any; + $parser?: (($viewValue: any, $setViewValue: ($newViewValue: any) => any) => T) | null; + $formatter?: (($modelValue: T, $setModelValue: ($newModelValue: T) => T) => any) | null; name?: string; component?: React.ComponentType; render?: (($fieldutil: $Fieldutil) => React.ReactNode); @@ -245,7 +244,7 @@ export interface $Fieldutil>): FieldState; $render($viewValue: any, callback?: () => void): FieldState; - $setValue($modelValue: any, callback?: () => void): FieldState; + $setValue($modelValue: T, callback?: () => void): FieldState; $setState(newState: Partial>, callback?: () => void): FieldState; $setTouched(touched: boolean, callback?: () => void): FieldState; $setDirty(dirty: boolean, callback?: () => void): FieldState;