공통 컴포런트에서 받은 데이타를 현재 페이지에 넘기기
This commit is contained in:
37
nuxt/components/DateSearch.vue
Normal file
37
nuxt/components/DateSearch.vue
Normal 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>
|
||||
Reference in New Issue
Block a user