实现思路 【vue中实现输入字数限制】使用计算属性监听输入文本的字数,如果超出字数,则使用字符串截取,截取限制长度
代码
{{descTitle}}
>{{descNum}}
/140
computed: {
descNum() {
if(this.descVal.length>=140){
this.descVal=this.descVal.substr(0,140);
return 140;
}
return this.descVal.length == 0?0:this.descVal.length;
}
},