공통 컴포런트에서 받은 데이타를 현재 페이지에 넘기기

This commit is contained in:
2024-11-03 09:01:02 +09:00
parent 05c39ed977
commit f78f096af5
2 changed files with 82 additions and 7 deletions

View File

@@ -0,0 +1,37 @@
<!-- DateSearch.vue -->
<template>
<div>
<label for="start-date">시작 날짜:</label>
<input type="date" v-model="startDate" id="start-date" />
<label for="end-date">종료 날짜:</label>
<input type="date" v-model="endDate" id="end-date" />
<button @click="searchData">검색</button>
</div>
</template>
<script setup>
import { ref, onMounted, defineEmits } from 'vue';
const startDate = ref('');
const endDate = ref('');
const emit = defineEmits(['search']);
const searchData = () => {
emit('search', { startDate: startDate.value, endDate: endDate.value });
};
const today = new Date();
const tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
startDate.value = formatDate(today);
endDate.value = formatDate(tomorrow);
function formatDate(date) {
return date.toISOString().split('T')[0];
}
</script>
<style scoped>
/* 필요한 스타일 */
</style>