html代码:
<el-input type="textarea"placeholder="请输入内容" v-model="textarea" :maxlength="maxlength" show-word-limit //展示字数统计:autosize="{ minRows: 2, maxRows: 4}" //高度能够根据文本内容自动进行调整@input="limitLength"></el-input>
data: {textarea: '',maxlength: 30},methods: {limitLength(value) {//value 为获取到的输入框的值if (value.length >= this.maxlength) {this.$el.querySelector('.el-input__count').style = 'color:red !important'} else {this.$el.querySelector('.el-input__count').style = 'color:#909399 !important'}}},
展示效果如下: