hjbky

一、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可以使用组件自带的方法。)

分类:

技术点:

相关文章:

  • 2021-12-08
  • 2021-12-08
  • 2021-11-15
  • 2021-11-05
  • 2021-12-08
  • 2021-12-08
  • 2021-12-28
  • 2021-08-17
猜你喜欢
  • 2021-12-25
  • 2021-12-28
  • 2021-12-25
  • 2021-11-05
  • 2021-12-08
  • 2021-12-08
  • 2021-12-08
相关资源
相似解决方案