wxml
代码语言:javascript复制 <view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__bd">
<textarea class="weui-textarea" placeholder="请输入文本" style="height: 3.3em" maxlength='100' bindinput='userInput' />
<view class="weui-textarea-counter">{{length}}/100</view>
</view>
</view>
</view>
这里要用bindinput
js
代码语言:javascript复制 data: {
...
length: 0
},
代码语言:javascript复制 //统计输入长度
userInput: function(e) {
console.log("输入的内容---" e.detail.value)
console.log("输入的长度---" e.detail.value.length)
this.setData({
length: e.detail.value.length
})
},