Update InputMask.vue

fix InputMask when use unmask and in certain cases (empty string), will show wrong value
pull/7377/head
吳彥東 2025-03-06 14:42:28 +08:00 committed by GitHub
parent 162d1a618f
commit 9a336c1274
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 1 deletions

View File

@ -454,10 +454,24 @@ export default {
return unmaskedBuffer.join('');
},
unmaskValue(value) {
let unmaskedBuffer = [];
let thisbuffer = value.split('');
for (let i = 0; i < thisbuffer.length; i++) {
let c = thisbuffer[i];
if (this.tests[i] && c !== this.getPlaceholder(i)) {
unmaskedBuffer.push(c);
}
}
return unmaskedBuffer.join('');
},
updateModelValue(value) {
if (this.currentVal === value) return;
const val = this.unmask ? this.getUnmaskedValue() : value;
const val = this.unmask ? this.unmaskValue(value) : value;
this.currentVal = value;