<textarea v-model="value" placeholder="输入内容" @input="inputArea()"></textarea>
new Vue({
el: ".box",
data: {
value: "",
maxLength: 100,
currentLength: 0
},
methods: {
inputArea() {
this.currentLength = this.value.length
if (this.currentLength > this.maxLength) {
this.currentLength = 100
this.value = this.value.slice(0, 100)
}
},
}
})