ManukMinasyan / vue-functional-calendar

Vue.js Functional Calendar | Component/Package
https://vue-functional-calendar.now.sh/
MIT License
467 stars 84 forks source link

How to reactively change the number of months in a calendar? #142

Closed atach closed 2 years ago

atach commented 2 years ago

I want to change the number of displayed months depending on the size of the screen. I change the "calendarsCount" property conditionally, but the calendar is not redrawn. How can this be done?

<FunctionalCalendar
            class="event-calendar"
            :calendarsCount="calendarCount"
        ></FunctionalCalendar>

export default {
    data() {
        return {
            calendarCount: 2
        }
    },
    methods: {
        updateWidth() {
            this.calendarCount = (window.innerWidth > 768) ? 2 : 1;
        }
    }
}
</script>
TitanFighter commented 2 years ago

Add v-if="showCalendar":

<FunctionalCalendar v-if="showCalendar" ... />

and when you need to redraw do it like:

this.showCalendar = false
this.$nextTick(() => {
  this.showCalendar = true
})
atach commented 2 years ago

Thank you