24年了,怎么让我也碰到了,裂开了。只能前端去做截取了
textarea组件输入字数超出最大输入长度后超出部分不显示但会成功输入一到两个字textarea设置maxlength为100,输入到第101个字时不显示,但成功输入,导致提交的数据出现长度限制的错误,代码片段如下: <textarea v-show="textareaVisibale" @input="textareaInput($event,100,'memberDesc')" v-model="addForm.memberDesc" :show-confirm-bar="showConfirm" auto-height="true" maxlength="100" :adjust-position="inputUp" @focus="inputFocus" @blur="inputBlur"/> 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)) } }, 测试结果如图: [图片]
06-19