.wxml
1 <view> 2 <view class="tit-main"> 3 请补充详细问题和意见 4 <text class="tit-deputy currentWordNumber">(必填,{{currentWordNumber|0}}/{{max}})</text> 5 </view> 6 <view class="idea"> 7 <textarea name="bindTextAreaBlur" bindinput="getValueLength" show-confirm-bar=‘true‘ maxlength="{{max}}"> 8 </textarea> 9 </view> 10 </view>
.js
1 data: { 2 max: 300, 3 param: { 4 content: ‘‘ 5 } 6 }, 7 getValueLength: function(e) { 8 let _this = this 9 let value = e.detail.value 10 let len = parseInt(value.length) 11 var param = this.data.param; 12 param.content = value 13 if (len > _this.data.max) return; 14 this.setData({ 15 currentWordNumber: len, 16 param: param 17 }) 18 }