Skip to content

Commit

Permalink
remove flag
Browse files Browse the repository at this point in the history
  • Loading branch information
yeriiiii committed Nov 27, 2023
1 parent 415789c commit 814f4db
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions packages/vlossom/src/components/vs-name-input/VsNameInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const VsNameInput = defineComponent({
return;
}
inputValue.value = modelValue.value || { firstName: '', lastName: '' };
emitValue(inputValue.value, 0);
emitValue(inputValue.value);
},
{ deep: true },
);
Expand All @@ -165,7 +165,7 @@ const VsNameInput = defineComponent({
return;
}
inputValue.value.firstName = firstNameValue.value || '';
emitValue(inputValue.value, 1);
emitValue(inputValue.value);
},
{ deep: true },
);
Expand All @@ -177,19 +177,15 @@ const VsNameInput = defineComponent({
return;
}
inputValue.value.lastName = lastNameValue.value || '';
emitValue(inputValue.value, 2);
emitValue(inputValue.value);
},
{ deep: true },
);
function emitValue(v: NameInputValue, flag: 0 | 1 | 2) {
if (flag! == 2) {
emit('update:firstName', v.firstName);
}
if (flag! == 1) {
emit('update:lastName', v.lastName);
}
function emitValue(v: NameInputValue) {
emit('update:modelValue', v);
emit('update:firstName', v.firstName);
emit('update:lastName', v.lastName);
checkRules(v);
updatedChanged(inputValue.value);
Expand All @@ -204,10 +200,10 @@ const VsNameInput = defineComponent({
const targetValue = target.value || '';
if (target.className === 'first-name') {
inputValue.value.firstName = targetValue;
emitValue(inputValue.value, 1);
emitValue(inputValue.value);
} else {
inputValue.value.lastName = targetValue;
emitValue(inputValue.value, 2);
emitValue(inputValue.value);
}
}
Expand Down Expand Up @@ -332,7 +328,7 @@ const VsNameInput = defineComponent({
function clear() {
inputValue.value.firstName = '';
inputValue.value.lastName = '';
emitValue(inputValue.value, 0);
emitValue(inputValue.value);
emit('clear');
}
Expand Down

0 comments on commit 814f4db

Please sign in to comment.