docs: form add preserve

pull/425/head
tangjinzhou 2019-01-19 17:53:55 +08:00
parent 19effd0885
commit ad0325a11e
4 changed files with 10 additions and 1 deletions

View File

@ -58,7 +58,7 @@ let id = 0;
export default { export default {
beforeCreate () { beforeCreate () {
this.form = this.$form.createForm(this); this.form = this.$form.createForm(this);
this.form.getFieldDecorator('keys', { initialValue: [] }); this.form.getFieldDecorator('keys', { initialValue: [], preserve: true });
}, },
data () { data () {
return { return {

View File

@ -154,6 +154,7 @@ After wrapped by `getFieldDecorator` or `v-decorator`, `value`(or other property
| options.getValueProps | Get the component props according to field value. | function(value): any | [reference](https://github.com/react-component/form#option-object) | options.getValueProps | Get the component props according to field value. | function(value): any | [reference](https://github.com/react-component/form#option-object)
| options.initialValue | You can specify initial value, type, optional value of children node. (Note: Because `Form` will test equality with `===` internally, we recommend to use variable as `initialValue`, instead of literal) | | n/a | | options.initialValue | You can specify initial value, type, optional value of children node. (Note: Because `Form` will test equality with `===` internally, we recommend to use variable as `initialValue`, instead of literal) | | n/a |
| options.normalize | Normalize value to form component, [a select-all example](https://codesandbox.io/s/kw4l2vqqmv) | function(value, prevValue, allValues): any | - | | options.normalize | Normalize value to form component, [a select-all example](https://codesandbox.io/s/kw4l2vqqmv) | function(value, prevValue, allValues): any | - |
| options.preserve | Keep the field even if field removed | boolean | false |
| options.rules | Includes validation rules. Please refer to "Validation Rules" part for details. | object\[] | n/a | | options.rules | Includes validation rules. Please refer to "Validation Rules" part for details. | object\[] | n/a |
| options.trigger | When to collect the value of children node | string | 'change' | | options.trigger | When to collect the value of children node | string | 'change' |
| options.validateFirst | Whether stop validate on first rule of error for this field. | boolean | false | | options.validateFirst | Whether stop validate on first rule of error for this field. | boolean | false |

View File

@ -152,6 +152,7 @@ validateFields(['field1', 'field2'], options, (errors, values) => {
| options.getValueFromEvent | 可以把 onChange 的参数(如 event转化为控件的值 | function(..args) | [reference](https://github.com/react-component/form#option-object) | | options.getValueFromEvent | 可以把 onChange 的参数(如 event转化为控件的值 | function(..args) | [reference](https://github.com/react-component/form#option-object) |
| options.initialValue | 子节点的初始值,类型、可选值均由子节点决定(注意:由于内部校验时使用 `===` 判断是否变化,建议使用变量缓存所需设置的值而非直接使用字面量)) | | | | options.initialValue | 子节点的初始值,类型、可选值均由子节点决定(注意:由于内部校验时使用 `===` 判断是否变化,建议使用变量缓存所需设置的值而非直接使用字面量)) | | |
| options.normalize | 转换默认的 value 给控件,[一个选择全部的例子](https://codesandbox.io/s/kw4l2vqqmv) | function(value, prevValue, allValues): any | - | | options.normalize | 转换默认的 value 给控件,[一个选择全部的例子](https://codesandbox.io/s/kw4l2vqqmv) | function(value, prevValue, allValues): any | - |
| options.preserve | 即便字段不再使用,也保留该字段的值 | boolean | false |
| options.rules | 校验规则,参考下方文档 | object\[] | | | options.rules | 校验规则,参考下方文档 | object\[] | |
| options.trigger | 收集子节点的值的时机 | string | 'change' | | options.trigger | 收集子节点的值的时机 | string | 'change' |
| options.validateFirst | 当某一规则校验不通过时,是否停止剩下的规则的校验 | boolean | false | | options.validateFirst | 当某一规则校验不通过时,是否停止剩下的规则的校验 | boolean | false |

View File

@ -143,6 +143,13 @@ declare interface FieldDecoratorOptions {
*/ */
normalize?: (value: any, prevValue: any, allValues: any) => any; normalize?: (value: any, prevValue: any, allValues: any) => any;
/**
* Keep the field even if field removed
* @default false
* @type boolean
*/
preserve?: boolean;
/** /**
* Includes validation rules. Please refer to "Validation Rules" part for details. * Includes validation rules. Please refer to "Validation Rules" part for details.
* @default n/a * @default n/a