0

I'm using v-calendar, I want to pass the default date to url and use it to set as the default date of the calendar.

The problem I faced with, is that v-calendar always shows the current date by default.

For example today is 30-01-2023 but I want to show the Feb of 2021.

I pass the default date in url query params.

My current code is like this:

<v-calendar
            class="custom-calendar max-w-full"
            :masks="masks"
            :attributes="filteredEvents"
            disable-page-swipe
            is-expanded
            :from-page="new Date(props.occurrence + '-01T:00:00')"
            v-bind="{
                fromDate: $props.occurrence ? new Date(occurrence+'01T00:00') : null,
            }"
            v-model="selectedDate"
            @update:from-page="navigationHandler($event)"
        >
            <template v-slot:day-content="{ day, attributes }">
              <CalendarDay :day="day" :attributes="attributes" />
            </template>
        </v-calendar>

If my props.occurrence = '2022-12, still the $event.year and month returns the current year and month.

jones
  • 1,423
  • 3
  • 35
  • 76
  • 1
    Does this answer your question? [Vue3 v-calendar how to open calendar to a particular past month](https://stackoverflow.com/questions/75062150/vue3-v-calendar-how-to-open-calendar-to-a-particular-past-month) – yoduh Jan 30 '23 at 20:41
  • @yoduh No it does not work, Inside method `navigationHandler($event)`, the $event year and month is always current year and month, even if I set its default value to a past year. For example I set 2019-1 and calendar shows Jan of 2019 but the event value is 2023-1. Very strange. – jones Jan 31 '23 at 17:05

0 Answers0