<textarea placeholder="写评论" maxlength="40" @input="descInput" v-model="orders" onchange="this.value=this.value.substring(0, 40)" onkeydown="this.value=this.value.substring(0, 40)" onkeyup="this.value=this.value.substring(0, 40)"> </textarea> <span>{{numbers}} / 40</span> data(){ return{ addshow:false, numbers:0, orders:'' } }, descInput(){ var txtVal = this.orders.length; this.numbers = txtVal },
转自:https://www.cnblogs.com/fanqiuzhuji/p/12689751.html