首页 > 编程知识 正文

vue的input限制输入长度,input限制输入长度

时间:2023-05-04 13:07:29 阅读:227191 作者:1549

一、watch方法:

<input v-model="textareaValue" type="textarea" placeholder="请输入。。。" style="width:100%; height:100px;"><p>还可以输入<span>{{10 - textareaValue.length}}</span>个字符</p> watch: { textareaValue(curVal, oldVal) { if (curVal.length > this.titleMaxLength) { this.textareaValue = String(curVal).slice(0, this.titleMaxLength); } }}

(我尝试使用iview-UI的input组件使用这个方法限制字符,存在问题。iview-UI可以使用组件自带的方法。)

转载于:https://www.cnblogs.com/hjbky/p/9258815.html

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。