vue 限制文本框字数(显示当前输入字符数量)

            <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
},
 

  

 

posted @ 2020-04-13 10:23  自律·给我自由  阅读(4355)  评论(0编辑  收藏  举报