Skip to content

Commit fa653af

Browse files
committed
fix: 修复 不设置label属性,label-width属性不生效的bug #327
1 parent 73e3af2 commit fa653af

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

uni_modules/uni-forms/changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.0.47
2+
- 修复 不设置label属性,label-width属性不生效的bug
3+
14
## 1.0.46(2021-06-04)
25
- 修复 动态删减数据导致报错的问题
36
## 1.0.45(2021-06-04)

uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<view class="uni-forms-item" :class="{ 'uni-forms-item--border': border, 'is-first-border': border && isFirstBorder, 'uni-forms-item-error': msg }">
33
<view class="uni-forms-item__box">
44
<view class="uni-forms-item__inner" :class="['is-direction-' + labelPos]">
5-
<view class="uni-forms-item__label" :style="{ width: labelWid + 'px', justifyContent: justifyContent }">
5+
<view class="uni-forms-item__label" :style="{ width: labelWid , justifyContent: justifyContent }">
66
<slot name="left">
77
<uni-icons v-if="leftIcon" class="label-icon" size="16" :type="leftIcon" :color="iconColor" />
88
<text class="label-text">{{ label }}</text>
@@ -191,8 +191,19 @@ export default {
191191
init() {
192192
if (this.form) {
193193
let { formRules, validator, formData, value, labelPosition, labelWidth, labelAlign, errShowType } = this.form;
194-
this.labelPos = this.labelPosition ? this.labelPosition : labelPosition;
195-
this.labelWid = this.label ? (this.labelWidth ? this.labelWidth : labelWidth) : 0;
194+
this.labelPos = this.labelPosition ? this.labelPosition : labelPosition;
195+
196+
if(this.label){
197+
this.labelWid = (this.labelWidth ? this.labelWidth : (labelWidth||65))
198+
}else{
199+
this.labelWid =( this.labelWidth ? this.labelWidth : (labelWidth||'auto'))
200+
}
201+
if(this.labelWid && this.labelWid !=='auto') {
202+
this.labelWid +='px'
203+
}
204+
console.log(this.labelWid);
205+
// this.labelWid = (this.labelWidth ? this.labelWidth : labelWidth) + 'px'
206+
// this.labelWid = this.label ? (this.labelWidth ? this.labelWidth : labelWidth) : 0;
196207
this.labelAli = this.labelAlign ? this.labelAlign : labelAlign;
197208
198209
// 判断第一个 item

uni_modules/uni-forms/components/uni-forms/uni-forms.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export default {
8989
// label 宽度,单位 px
9090
labelWidth: {
9191
type: [String, Number],
92-
default: 65
92+
default: ''
9393
},
9494
// label 居中方式,可选值 left/center/right
9595
labelAlign: {

0 commit comments

Comments
 (0)