textarea组件输入字数超出最大输入长度后超出部分不显示但会成功输入一到两个字 |
您所在的位置:网站首页 › pages不显示字数 › textarea组件输入字数超出最大输入长度后超出部分不显示但会成功输入一到两个字 |
textarea设置maxlength为100,输入到第101个字时不显示,但成功输入,导致提交的数据出现长度限制的错误,代码片段如下: textareaInput(event,maxlength,propertyName){ if(event.detail.cursor==maxlength){ uni.showToast({ title:'最多只能输入'+maxlength+'个字!', icon:'none', duration:2000 }) }else if(event.detail.cursor>maxlength){ uni.showToast({ title:'最多只能输入'+maxlength+'个字!', icon:'none', duration:2000 }) console.log('event.detail.cursor:',event.detail.cursor); console.log('event.detail.value:',event.detail.value); console.log('this.addForm[propertyName]:',this.addForm[propertyName]); // this.addForm[propertyName]=this.addForm[propertyName].substring(0,maxlength) // this.$set(event.detail,'value',event.detail.value.substring(0,maxlength)) } }, 测试结果如图: |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |