Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
form 组件:$form.validateField 方法的参数只需要传字段名,更新了文档
Browse files Browse the repository at this point in the history
  • Loading branch information
xxapp committed Aug 12, 2017
1 parent fc6bb91 commit 32fe71b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/ms-form/create-form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Form.prototype.trigger = function (type: string, payload) {
}

Form.prototype.validateField = async function (fieldName, field) {
field = field || this.fields[fieldName];
const rules = field.rules;
const value = getValue(this.record, fieldName);
let result: any = { isOk: true, name: fieldName };
Expand Down
12 changes: 11 additions & 1 deletion components/ms-form/ms-form.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ const vm = avalon.define({
});
}
})
/*
// 验证某个字段
vm.$form.validateField('title').then(result => {
if (!result.isOk) {
message.success({
content: result.message
});
}
})
*/
}
});
```
Expand Down Expand Up @@ -110,6 +120,6 @@ $form 对象可访问的属性如下:
| fields | 所有的字段集合 | { \[string\]: meta } |
| setFieldsValue | 设置字段值的方法 | (fields) => void |
| addFields | 添加字段 | (fields) => void |
| validateField | 验证某个字段 | (fieldName, field) => Promise<{isOk: boolean, name: string, message: string}> |
| validateField | 验证某个字段 | (fieldName) => Promise<{isOk: boolean, name: string, message: string}> |
| validateFields | 验证多个或者所有字段 | (field?) => Promise&#x3C;boolean&#x3E; |
| resetFields | 重置多个或者所有字段 | (field?) => void |

1 comment on commit 32fe71b

@xxapp
Copy link
Owner Author

@xxapp xxapp commented on 32fe71b Aug 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed #7

Please sign in to comment.