1.fullcalendar组件效果图如下所示

官网地址:https://fullcalendar.io/
2.下载安装
npm install --save @fullcalendar/vue
npm install --save @fullcalendar/core @fullcalendar/daygrid @fullcalendar/interaction @fullcalendar/list @fullcalendar/timegrid
npm install --save dayjs
<template>
<div>
<FullCalendar ref="myCalendar" :options="calendarOptions" />
</div>
</template>
<script>
import FullCalendar from "@fullcalendar/vue"
import dayGridPlugin from "@fullcalendar/daygrid"
import timeGridPlugin from "@fullcalendar/timegrid"
import interactionPlugin from "@fullcalendar/interaction"
import listPlugin from "@fullcalendar/list"
import dayjs from "dayjs"
export default {
name: "MaintenanceCalendarview",
components: {
FullCalendar
},
data() {
return {
calendarOptions: {
defaultView: "agendaWeek",
plugins: [dayGridPlugin, interactionPlugin, timeGridPlugin, listPlugin],
initialView: "dayGridMonth",
firstDay: 1,
locale: "zh-cn",
eventColor: "#3BB2E3",
themeSystem: "bootstrap",
initialDate: dayjs().format("YYYY-MM-DD"),
aspectRatio: 1.65,
headerToolbar: {
left: "",
center: "prevYear,prev title next,nextYear",
right: "today dayGridMonth,timeGridWeek,timeGridDay"
},
buttonText: {
today: "今天",
month: "月",
week: "周",
day: "日"
},
slotLabelFormat: {
hour: "2-digit",
minute: "2-digit",
meridiem: false,
hour12: false
},
eventClick: this.handleEventClick,
eventDblClick: this.handleEventDblClick,
eventClickDelete: this.eventClickDelete,
eventDrop: this.eventDrop,
eventResize: this.eventResize,
select: this.handleDateSelect,
eventDidMount: this.eventDidMount,
eventMouseEnter: this.eventMouseEnter,
editable: false,
eventStartEditable: false,
eventDurationEditable: false,
selectable: true,
selectMirror: true,
selectMinDistance: 50,
dayMaxEvents: true,
weekends: true,
navLinks: true,
slotEventOverlap: false,
events: [
{
title: "任务1",
start: "2024-08-01 12:30",
end: "2024-08-01 14:30",
duration: "03:00",
url: "https://www.baidu.com/"
},
{
title: "任务11",
start: "2024-08-01 12:30",
end: "2024-08-01 14:30",
duration: "03:00",
url: "https://www.baidu.com/"
},
{
title: "任务111",
start: "2024-08-01 12:30",
end: "2024-08-01 14:30",
duration: "03:00",
url: "https://www.baidu.com/"
},
{
title: "任务2",
start: "2024-08-02 00:00",
end: "2024-08-02 23:59",
color: "red"
},
{
title: "任务3",
start: "2024-08-12",
end: "2024-08-16",
color: "green"
},
{ title: "任务4", date: "2024-08-19", classNames: ["cal"] },
{
title: "任务5",
start: "2024-08-27",
end: "2024-08-29",
overlap: false,
display: "background",
color: "#ff9f89"
}
]
}
}
},
methods: {
eventMouseEnter(event, jsEvent, view) {
if (event.event.classNames.length) {
}
},
eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
console.log(event)
},
handleEventClick(ev, a, b) {
console.log(ev, a, b)
}
}
}
</script>
<style lang="scss" scoped>
::v-deep .fc-toolbar-chunk {
display: flex;
}
</style>