[new feature] Field: add label-width prop (#3235)

This commit is contained in:
neverland
2019-04-29 11:31:52 +08:00
committed by GitHub
parent 0b774ed7c0
commit 9fe0831e6d
5 changed files with 55 additions and 1 deletions
+14
View File
@@ -3,6 +3,7 @@ import Cell from '../cell';
import { cellProps } from '../cell/shared';
import { use, isObj, isDef, isIOS } from '../utils';
import { getRootScrollTop } from '../utils/scroll';
import { isNumber } from '../utils/validate/number';
const [sfc, bem] = use('field');
@@ -16,6 +17,7 @@ export default sfc({
rightIcon: String,
readonly: Boolean,
clearable: Boolean,
labelWidth: [String, Number],
labelAlign: String,
inputAlign: String,
onIconClick: Function,
@@ -60,6 +62,17 @@ export default sfc({
focus: this.onFocus,
blur: this.onBlur
};
},
labelStyle() {
const { labelWidth } = this;
if (labelWidth) {
const width = isNumber(String(labelWidth)) ? `${labelWidth}px` : labelWidth;
return {
maxWidth: width,
minWidth: width
};
}
}
},
@@ -237,6 +250,7 @@ export default sfc({
border={this.border}
isLink={this.isLink}
required={this.required}
titleStyle={this.labelStyle}
titleClass={bem('label', labelAlign)}
class={bem({
error: this.error,