feat(Form): add label-align prop

This commit is contained in:
陈嘉涵 2020-02-13 16:00:50 +08:00
parent fbe3d20558
commit f1e25123a3
4 changed files with 13 additions and 1 deletions

View File

@ -433,10 +433,19 @@ export default createComponent({
); );
} }
}, },
getProp(key) {
if (this.vanForm && isDef(this.vanForm[key])) {
return this.vanForm[key];
}
return this[key];
},
}, },
render() { render() {
const { slots, labelAlign } = this; const { slots } = this;
const labelAlign = this.getProp('labelAlign');
const scopedSlots = { const scopedSlots = {
icon: this.genLeftIcon, icon: this.genLeftIcon,

View File

@ -405,6 +405,7 @@ export default {
| Attribute | Description | Type | Default | | Attribute | Description | Type | Default |
|------|------|------|------| |------|------|------|------|
| label-align | Label text align, can be set to `center` `right` | *string* | `left` |
| validate-first | Whether to stop the validation when a rule fails | *boolean* | `false` | | validate-first | Whether to stop the validation when a rule fails | *boolean* | `false` |
### Events ### Events

View File

@ -437,6 +437,7 @@ export default {
| 参数 | 说明 | 类型 | 默认值 | | 参数 | 说明 | 类型 | 默认值 |
|------|------|------|------| |------|------|------|------|
| label-align | 表单项左侧文本对齐方式,可选值为 `center` `right` | *string* | `left` |
| validate-first | 是否在某一项校验不通过时停止校验 | *boolean* | `false` | | validate-first | 是否在某一项校验不通过时停止校验 | *boolean* | `false` |
### Events ### Events

View File

@ -4,6 +4,7 @@ const [createComponent, bem] = createNamespace('form');
export default createComponent({ export default createComponent({
props: { props: {
labelAlign: String,
validateFirst: Boolean, validateFirst: Boolean,
}, },