update:alert 추가
This commit is contained in:
parent
7e484c12be
commit
a7c27a19e4
@ -82,7 +82,8 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Emits 정의
|
// Emits 정의
|
||||||
const emits = defineEmits(['update:modelValue', 'focusout']);
|
const emits = defineEmits(['update:modelValue', 'focusout', 'update:alert']);
|
||||||
|
|
||||||
|
|
||||||
// 로컬 상태로 사용하기 위한 `inputValue`
|
// 로컬 상태로 사용하기 위한 `inputValue`
|
||||||
const inputValue = ref(props.modelValue);
|
const inputValue = ref(props.modelValue);
|
||||||
@ -90,6 +91,11 @@ const inputValue = ref(props.modelValue);
|
|||||||
// 부모로 데이터 업데이트
|
// 부모로 데이터 업데이트
|
||||||
watch(inputValue, (newValue) => {
|
watch(inputValue, (newValue) => {
|
||||||
emits('update:modelValue', newValue);
|
emits('update:modelValue', newValue);
|
||||||
|
|
||||||
|
// 값이 입력될 때 `alert`를 false로 설정
|
||||||
|
if (newValue.trim() !== '') {
|
||||||
|
emits('update:alert', false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 초기값 동기화
|
// 초기값 동기화
|
||||||
@ -98,10 +104,7 @@ watch(() => props.modelValue, (newValue) => {
|
|||||||
inputValue.value = newValue;
|
inputValue.value = newValue;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
.none {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user