Skip to content

Commit 72444bc

Browse files
committed
fix(Textarea): 修复安卓平台字数统计显示不准确的问题
close #1328
1 parent 540b338 commit 72444bc

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/core/wxs/math.wxs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function min(a,b){
2+
return Math.min(a,b);
3+
}
4+
5+
module.exports = {
6+
min:min
7+
}

src/textarea/index.wxml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<!-- input/input.wxml -->
1+
<wxs src="../core/wxs/math.wxs" module="Math" />
2+
23
<label class='form-item {{disabled? "disabled": ""}}'>
34
<view class='default-border {{border? "border": ""}} l-class'>
45
<view class='mask' wx:if="{{disabled}}"></view>
@@ -21,9 +22,8 @@
2122
bindblur="handleInputBlur"
2223
bindconfirm="handleInputConfirm"
2324
/>
24-
<view
25-
class="indicator"
26-
wx:if="{{indicator}}">{{value.length + '/' + maxlength}}</view>
25+
<!-- 使用 Math.min 的原因:在安卓平台上,由于微信的 bug,value.length 会超过 maxlength,导致显示不准确 -->
26+
<view class="indicator" wx:if="{{indicator}}">{{Math.min(value.length,maxlength) + '/' + maxlength}}</view>
2727
</view>
2828
</label>
2929
<l-error-tip l-error-text-class="l-error-text l-error-text-class" errorText="{{errorText}}" wx:if="{{errorText}}"/>

0 commit comments

Comments
 (0)