Merge pull request #5330 from fanburger/fix/5308

fix(van-field): Invalid maxlength on Android devices
This commit is contained in:
landluck 2023-04-20 11:23:10 +08:00 committed by GitHub
commit 4a3dbff38b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,6 +76,13 @@ VantComponent({
const { value = '' } = event.detail || {};
this.value = value;
const { maxlength } = this.data;
if (maxlength !== -1 && value.length > maxlength) {
this.value = value.slice(0, maxlength);
event.detail.value = this.value;
}
this.setShowClear();
this.emitChange(event.detail);