update:alert 추가
This commit is contained in:
parent
7e484c12be
commit
a7c27a19e4
@ -14,7 +14,7 @@
|
|||||||
:placeholder="title"
|
:placeholder="title"
|
||||||
:disabled="disabled"
|
:disabled="disabled"
|
||||||
:min="min"
|
:min="min"
|
||||||
@focusout="$emit('focusout', modelValue)"
|
@focusout="$emit('focusout', modelValue)"
|
||||||
/>
|
/>
|
||||||
<div class="invalid-feedback" :class="isAlert ? 'display-block' : ''">
|
<div class="invalid-feedback" :class="isAlert ? 'display-block' : ''">
|
||||||
{{ title }}을 확인해주세요.
|
{{ title }}을 확인해주세요.
|
||||||
@ -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