Skip to main content

getEvents

Returns the calendar's event list. With no arguments it returns every stored event. With start and end, it returns only events that overlap that range.

Usage

getEvents(start?: Date, end?: Date): CalendarEvent[];

Parameters:

ParameterTypeDescription
startDateOptional range start. Returns events ending at or after this date.
endDateOptional range end. Returns events starting at or before this date.

Returns: CalendarEvent[].

FieldTypeDescription
idstring | numberUnique event id.
startDateEvent start time.
endDateEvent end time.
allDaybooleanOptional. All-day flag.
[key]anyCustom fields preserved on the event.

When recurring is enabled, the returned list contains expanded occurrences, not master events.

Example

<script setup lang="ts">
import { ref } from "vue";
import { Calendar } from "@wx/vue-calendar";
import type { CalendarInstanceApi } from "@wx/vue-calendar";

const api = ref<CalendarInstanceApi | undefined>();

function exportAll() {
const all = api.value.getEvents();
console.log(all);
}

function exportThisWeek() {
const start = new Date();
const end = new Date();
end.setDate(start.getDate() + 7);
const events = api.value.getEvents(start, end);
console.log(events);
}
</script>

<template>
<Calendar :events="events" ref="api" />
<button :onclick="exportAll">All events</button>
<button :onclick="exportThisWeek">This week</button>
</template>