Эх сурвалжийг харах

fix form validate callback params

baiyaaaaa 8 жил өмнө
parent
commit
e7e104df5d

+ 4 - 4
examples/docs/en-US/form.md

@@ -809,10 +809,10 @@ Form component allows you to verify your data, helping you find and correct erro
 
 ### Form Methods
 
-| Method | Description |
-| ---- | ---- |
-| validate(cb) | the method to validate the whole form |
-| validateField(prop, cb) | the method to validate a certain form item |
+| Method | Description | params
+| ---- | ---- | ----
+| validate | the method to validate the whole form | Function(callback: Function(boolean))
+| validateField | the method to validate a certain form item | Function(prop: string, callback: Function(errorMessage: string))
 | resetFields | reset all the fields and remove validation result |
 
 ### Form-Item Attributes

+ 5 - 5
examples/docs/zh-CN/form.md

@@ -799,11 +799,11 @@
 
 ### Form Methods
 
-| 方法名      | 说明          |
-|---------- |-------------- |
-| validate(cb) | 对整个表单进行校验的方法 |
-| validateField(prop, cb) | 对部分表单字段进行校验的方法 |
-| resetFields | 对整个表单进行重置,将所有字段值重置为空并移除校验结果 |
+| 方法名      | 说明          | 参数
+|---------- |-------------- | --------------
+| validate | 对整个表单进行校验的方法 | Function(callback: Function(boolean))
+| validateField | 对部分表单字段进行校验的方法 | Function(prop: string, callback: Function(errorMessage: string))
+| resetFields | 对整个表单进行重置,将所有字段值重置为空并移除校验结果 | -
 
 ### Form-Item Attributes
 

+ 1 - 1
packages/form/src/form-item.vue

@@ -139,7 +139,7 @@
           this.validateState = !errors ? 'success' : 'error';
           this.validateMessage = errors ? errors[0].message : '';
 
-          callback(errors);
+          callback(this.validateMessage);
         });
       },
       resetField() {