Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Textarea): 修复安卓平台字数统计显示不准确的问题 #1366

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions src/core/wxs/math.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function min(a,b){
return Math.min(a,b);
}

module.exports = {
min:min
}
8 changes: 4 additions & 4 deletions src/textarea/index.wxml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- input/input.wxml -->
<wxs src="../core/wxs/math.wxs" module="Math" />

<label class='form-item {{disabled? "disabled": ""}}'>
<view class='default-border {{border? "border": ""}} l-class'>
<view class='mask' wx:if="{{disabled}}"></view>
Expand All @@ -21,9 +22,8 @@
bindblur="handleInputBlur"
bindconfirm="handleInputConfirm"
/>
<view
class="indicator"
wx:if="{{indicator}}">{{value.length + '/' + maxlength}}</view>
<!-- 使用 Math.min 的原因:在安卓平台上,由于微信的 bug,value.length 会超过 maxlength,导致显示不准确 -->
<view class="indicator" wx:if="{{indicator}}">{{Math.min(value.length,maxlength) + '/' + maxlength}}</view>
</view>
</label>
<l-error-tip l-error-text-class="l-error-text l-error-text-class" errorText="{{errorText}}" wx:if="{{errorText}}"/>