wxml
<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">{{num}}/100</view>
</view>
</view>
</view>
這裏要用bindinput
js
data: {
...
num: 0
},
//統計輸入長度
userInput: function(e) {
console.log("輸入的內容---" + e.detail.value)
console.log("輸入的長度---" + e.detail.cursor)
this.setData({
num: e.detail.cursor
})
},