vue.js文本框字数限制

<div>
                    <textarea placeholder="填写服务备注" style="width:100%; border:solid 1px #d8d8d8; border-radius:3px; font-size:14px; padding:10px;" rows="3" maxlength="50" @input="descInput"
v-model="desc"></textarea>
                    <p class="pay-service-textarea-text"><span>{{remnant}}</span>/50</p>

</div>

<script>

export default {
    data() {
            return {

       remnant:0

    }

    },

methods: {
            descInput() {
                var txtVal = this.desc.length;  //desc 是设置v-model的值
                this.remnant = txtVal;
        }

}

  }

</script>

posted @ 2017-06-28 10:13  安心牧羊人  阅读(6950)  评论(0编辑  收藏  举报