Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/textarea/textarea.less
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@import '../common/style/index.less';

@textarea-height: 72px; // 指定文本框高度
@textarea-height: 144rpx; // 指定文本框高度
@textarea-vertical-padding: 32rpx; // 文本框垂直方向间距
@textarea-horizontal-padding: 32rpx; // 文本框水平方向间距
@textarea-text-line-height: 48rpx; // 输入框文本行高
@textarea-label-line-height: 44px; // 标签文本行高
@textarea-label-line-height: 44rpx; // 标签文本行高
@textarea-label-padding-bottom: @spacer;
@textarea-indicator-text-line-height: 40rpx; // 计数器文本行高
@textarea-indicator-text-padding-top: @spacer; // 计数器文本顶部间距
Expand Down Expand Up @@ -61,7 +61,7 @@
border: 0;
resize: none;
font-size: @textarea-text-font-size;
color: @textarea-text-font-size;
color: @textarea-text-color;
line-height: @textarea-text-line-height;
}
}
Expand Down
15 changes: 7 additions & 8 deletions src/textarea/textarea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ export default class Textarea extends SuperComponent {
count: 0,
};

lifetimes = {
ready() {
const { value } = this.properties;
this.updateValue(value);
observers = {
value(val) {
this.updateValue(val);
},
};

Expand All @@ -50,18 +49,18 @@ export default class Textarea extends SuperComponent {
if (maxcharacter > 0 && !Number.isNaN(maxcharacter)) {
const { length, characters } = getCharacterLength('maxcharacter', value, maxcharacter);
this.setData({
value: characters,
computedValue: characters,
count: length,
});
} else if (maxlength > 0 && !Number.isNaN(maxlength)) {
const { length, characters } = getCharacterLength('maxlength', value, maxlength);
this.setData({
value: characters,
computedValue: characters,
count: length,
});
} else {
this.setData({
value,
computedValue: value,
count: value ? String(value).length : 0,
});
}
Expand All @@ -70,7 +69,7 @@ export default class Textarea extends SuperComponent {
onInput(event) {
const { value } = event.detail;
this.updateValue(value);
this.triggerEvent('change', { value: this.data.value });
this.triggerEvent('change', { value: this.data.computedValue });
},
onFocus(event) {
this.triggerEvent('focus', {
Expand Down
2 changes: 1 addition & 1 deletion src/textarea/textarea.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
placeholder="{{placeholder}}"
placeholder-class="{{classPrefix}}__placeholder"
placeholder-style="{{placeholderStyle}}"
value="{{value}}"
value="{{computedValue}}"
auto-focus="{{autofocus}}"
fixed="{{fixed}}"
focus="{{focus}}"
Expand Down