Refactor dateValue initialization in DatePicker.vue

This commit is contained in:
Dede Fuji Abdul
2024-04-07 04:53:55 +07:00
parent 253a076107
commit 4943cbec09

View File

@ -4,7 +4,7 @@ import { onMounted, ref, watch } from 'vue'
import VueTailwindDatepicker from 'vue-tailwind-datepicker' import VueTailwindDatepicker from 'vue-tailwind-datepicker'
const dateValue = ref( const dateValue = ref(
`${new Date().getDay().toString().length == 1 ? `0${new Date().getDay()}` : new Date().getDay()}-${(new Date().getMonth() + 1).toString().length == 1 ? `0${new Date().getMonth() + 1}` : new Date().getMonth() + 1}-${new Date().getFullYear()} s/d ${new Date().getDay().toString().length == 1 ? `0${new Date().getDay()}` : new Date().getDay()}-${(new Date().getMonth() + 1).toString().length == 1 ? `0${new Date().getMonth() + 1}` : new Date().getMonth() + 1}-${new Date().getFullYear()}` `${new Date().getDate().toString().length == 1 ? `0${new Date().getDate()}` : new Date().getDate()}-${(new Date().getMonth() + 1).toString().length == 1 ? `0${new Date().getMonth() + 1}` : new Date().getMonth() + 1}-${new Date().getFullYear()} s/d ${new Date().getDate().toString().length == 1 ? `0${new Date().getDate()}` : new Date().getDate()}-${(new Date().getMonth() + 1).toString().length == 1 ? `0${new Date().getMonth() + 1}` : new Date().getMonth() + 1}-${new Date().getFullYear()}`
) )
const formatter = ref({ const formatter = ref({
date: 'DD-MM-YYYY', date: 'DD-MM-YYYY',
@ -79,6 +79,7 @@ watch(dateValue, (newValue) => {
onMounted(() => { onMounted(() => {
emit('update:dateValue', dateValue.value) emit('update:dateValue', dateValue.value)
console.log('current date', dateValue.value)
}) })
</script> </script>