Vue.js 完整日历Vue JS组件-添加事件

Vue.js 完整日历Vue JS组件-添加事件,vue.js,fullcalendar,fullcalendar-5,Vue.js,Fullcalendar,Fullcalendar 5,我正在使用Vue JS的完整日历: 我似乎找不到使用完整的日历Vue JS组件添加事件的方法。我看到示例执行此操作的唯一方法是掌握日历的API并通过它创建事件。这似乎有点反vue 文档演示: handleDateSelect(selectInfo) { let title = prompt('Please enter a new title for your event') let calendarApi = selectInfo.view.calendar

我正在使用Vue JS的完整日历:

我似乎找不到使用完整的日历Vue JS组件添加事件的方法。我看到示例执行此操作的唯一方法是掌握日历的API并通过它创建事件。这似乎有点反vue

文档演示:

 handleDateSelect(selectInfo) {
      let title = prompt('Please enter a new title for your event')
      let calendarApi = selectInfo.view.calendar
      calendarApi.unselect() // clear date selection
      if (title) {
        calendarApi.addEvent({
          id: createEventId(),
          title,
          start: selectInfo.startStr,
          end: selectInfo.endStr,
          allDay: selectInfo.allDay
        })
      }
    }

我想知道,通过点击日历本机API(如上所示)在Vue JS完整日历上创建事件的唯一方法是什么?是否没有办法将某种类型的事件发送到组件中?

您实际上不必回过头来使用命令式实例API。Vue
FullCalendar
组件将
事件作为您可以使用的选项的一部分公开。例如:

<template>
  <FullCalendar :options="opts" />
  <button @click="addNewEvent"></button>
</template>
export default {
  data() {
    return {
      opts: {
        plugins: [ /* Any addition plugins you need */ ],
        initialView: 'dayGridMonth',
        events: [
          { title: 'First Event', date: '2021-05-12' },
          /* Few more initial events */
        ]
      }
    }
  },
  methods: {
    addNewEvent() {
      this.opts.events = [
        ...this.opts.events,
        { title: 'Another Event', date: '2021-05-13' }
      ];
    }
  }
}