了解Vue中日历插件Fullcalendar
实现效果如下图:
月视图
周视图
日视图
官方文档地址:Vue Component - Docs | FullCalendar
1、安装与FullCalendar相关的依赖项
npm install --save @fullcalendar/vue @fullcalendar/core @fullcalendar/daygrid @fullcalendar/timegrid @fullcalendar/list
npm install --save @fullcalendar/interaction
npm install --save @fullcalendar/core @fullcalendar/resource-timeline
2.使用日历的页面需要导入
import FullCalendar from "@fullcalendar/vue";
import dayGridPlugin from "@fullcalendar/daygrid";
import timeGridPlugin from "@fullcalendar/timegrid";
import listPlugin from "@fullcalendar/list";
import interactionPlugin from "@fullcalendar/interaction";
// import resourceTimelinePlugin from "@fullcalendar/resource-timeline";
完整代码
<template><div><div class="fc-toolbar"><div class="fc-left"><el-button-group><el-button @click="month"> 月 </el-button><el-button @click="week"> 周 </el-button><el-button @click="today"> 今天 </el-button></el-button-group></div><div class="fc-center"><el-button icon="el-icon-arrow-left" @click="prev"/><p class="title">{{ title }}</p><el-button icon="el-icon-arrow-right" @click="next" /></div><div><el-select v-model="type" style="margin-right: 20px" @change="handleType"><el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" /></el-select><el-button class="search" style="margin-right: 20px" type="button" @click="addEvent">新增</el-button><el-button class="search" type="button" @click="search">查询</el-button></div></div><el-dialog title="添加日程" :visible.sync="dialogFormVisible" width="600px"><el-form :model="form"><el-form-item label="事件"><el-input v-model="form.content" autocomplete="off" placeholder="请输入事件"></el-input></el-form-item></el-form><div slot="footer" class="dialog-footer"><el-button @click="dialogFormVisible = false">取 消</el-button><el-button type="primary" @click="navConfirm">确 定</el-button></div></el-dialog><div v-if="showFullcalendar">加载数据中......</div><FullCalendar v-else id="calendar" ref="fullCalendar" class="demo-app-calendar" :options="calendarOptions"><template v-slot:eventContent="arg"><el-popover placement="top-start" title="标题" width="200" :visible-arrow="false" trigger="click"><i class="title">{{ arg.event.title }}</i><el-button @click="more(arg.event)"> 更多 </el-button><div slot="reference" class="popper-content"><span>{{ arg.timeText }}</span><i>{{ arg.event.title }}</i></div></el-popover></template><template v-slot:dayCellContent="arg">{{ arg.dayNumberText }}</template><template v-slot:resourceLabelContent="arg">{{ arg.resource.id }}</template></FullCalendar></div>
</template>
<script>import FullCalendar from "@fullcalendar/vue";import dayGridPlugin from "@fullcalendar/daygrid";import timeGridPlugin from "@fullcalendar/timegrid";import listPlugin from "@fullcalendar/list";import interactionPlugin from "@fullcalendar/interaction";// import resourceTimelinePlugin from "@fullcalendar/resource-timeline";let clickCount = 0;let prev = ""; // 上一次点击的dom节点export default {components: {FullCalendar, // make the <FullCalendar> tag available},data() {return {showFullcalendar: true,title: "",currentView: {},options: [{ value: "timeline", label: "resource-timeline" },{ value: "dategrid", label: "agenda" },],type: "dategrid",calendarOptions: {locale: "zh",timeZone: "UTC",plugins: [dayGridPlugin,timeGridPlugin,listPlugin,// resourceTimelinePlugin,interactionPlugin,],buttonText: {// 设置按钮today: "今天",month: "月",week: "周",dayGrid: "天",},initialView: "dayGridMonth", // 设置默认显示月,可选周、日resourceAreaWidth: 200,contentHeight: 600,slotMinWidth: 70,resourceOrder: "number",editable: true,dayMaxEvents: true, // allow "more" link when too many eventseventDurationEditable: true, // 可以调整事件的时间selectable: true, // 日历格子可选择nowIndicator: true, // 现在的时间线显示eventDisplay: "block", // 争对全天的情况下,以块状显示headerToolbar: false, // 隐藏头部的导航栏selectMirror: false,displayEventEnd: true, // like 08:00 - 13:00eventTimeFormat: {// like '14:30:00'hour: "2-digit",minute: "2-digit",meridiem: false,hour12: false, // 设置时间为24小时},events: [],eventColor: "#378006",allDayText: "全天",dateClick: this.handleDateClick, //点击日程事件eventClick: this.handleEventClick, //点击日历中的某一日程select:this.handleDateSelect, // 监听用户选择的时间段,eventDrop:this.handleEventDrop, //监听事件被拖动的操作eventResize:this.handleEventResize, //监听事件调整大小的操作resourceAreaHeaderContent: "Rooms",resources: [{id: "111",title: "asas",number: 1,},],schedulerLicenseKey: "GPL-My-Project-Is-Open-Source",resourceLabelContent(arg) {return {html: `<div>id: ${arg.resource.id}</div><div>title: ${arg.resource.title}</div>`,};},views: {customTimeLineWeek: {type: "resourceTimeline",duration: { weeks: 1 },slotDuration: { days: 1 },buttonText: "Custom Week",slotLabelFormat: {weekday: "long",// month: 'numeric',// day: 'numeric',omitCommas: true,},},customTimeLineMonth: {type: "resourceTimeline",duration: { month: 1 },slotLabelFormat: {// month: 'numeric',day: "numeric",// omitCommas: true,},},customGridWeek: {type: "timeGridWeek",dayHeaderFormat: {weekday: "long",},slotLabelFormat: {// 左侧时间格式hour: "2-digit",minute: "2-digit",meridiem: "lowercase",hour12: false, // false设置时间为24小时},},},// 切换视图调用的方法datesSet() { },},calendarApi: null,monthEvent: [{id: "1",resourceId: "1",title: "待办",start: "2024-01-04 09:00",end: "2024-01-04 18:00",color: "red",},{resourceId: "2",id: "2",title: "待办",start: "2024-01-15",color: "purple",},{ title: "待办", start: "2024-01-09" },{ title: "待办", start: "2024-01-17" },{ title: "待办", start: "2024-01-07" },{ title: "待办", start: "2024-01-07", color: "pink" },{ title: "待办", start: "2024-01-07" },{ title: "待办", start: "2024-01-07" },{id: "3",resourceId: "number_3",title: "待办",start: "20240111",end: "20240113",color: "blue",extendedProps: {description: "测试测试测试测试",},},{id: 4,title: "待办",start: "2024-01-15",extendedProps: {description: "test test test test test",},},],weekEvent: [{id: "4",resourceId: "4",title: "周待办",start: "2024-01-11",color: "red",},{id: "5",resourceId: "5",title: "待办1",start: "2024-01-04 10:00",end: "2024-01-04 18:00",color: "orange",},],dayDate:'',dialogFormVisible:false,form:{content:'',},selectInfo:{},};},mounted() {setTimeout(() => {this.showFullcalendar = false;this.$nextTick(() => {this.calendarApi = this.$refs.fullCalendar.getApi();this.title = this.calendarApi.view.title;this.getDtata();});}, 1000);},watch: {// 切换视图显示不同的事件"calendarApi.view.type"(newVal) {this.getDtata();},},methods: {// 监听用户选择的时间段,当用户选择了一段时间后会触发该回调,可以在这里处理创建新的日程。handleDateSelect(selectInfo) {console.log('selectInfo: ', selectInfo);this.selectInfo = selectInfo;this.form.content = '';// 用户选择了一个日期范围时触发this.dialogFormVisible = true;},// 用户拖动移动事件时触发handleEventDrop(dropInfo) {console.log('dropInfo: ', dropInfo);const updatedEvent = { ...dropInfo.event };updatedEvent.start = dropInfo.revertDuration ? dropInfo.oldEvent.start : dropInfo.event.start;updatedEvent.end = dropInfo.event.end;// 更新服务器上的事件或者重新排序你的事件数组// 示例:this.updateEventOnServer(updatedEvent);// 如果是在内存中维护事件,则更新本地数据const index = this.events.findIndex(e => e.id === updatedEvent.id);if (index !== -1) {this.events.splice(index, 1, updatedEvent);}},// 用户调整事件长度时触发handleEventResize(resizeInfo) {console.log('resizeInfo: ', resizeInfo);const updatedEvent = { ...resizeInfo.event };updatedEvent.end = resizeInfo.event.end;// 同样更新服务器或本地数据// 示例:this.updateEventOnServer(updatedEvent);const index = this.events.findIndex(e => e.id === updatedEvent.id);if (index !== -1) {this.events.splice(index, 1, updatedEvent);}},getDtata() {setTimeout(() => {this.calendarOptions.events =this.calendarApi.view.type === "dayGridMonth"? this.monthEvent: this.weekEvent;}, 200);},// 点击更多more(e) { console.log('more ', e)},//确认弹框按钮navConfirm(){this.dialogFormVisible = false;if (this.form.content) {this.calendarOptions.events.push({title: this.form.content,start: this.selectInfo.startStr,end: this.selectInfo.endStr,});// 更新日历视图以显示新添加的事件this.$refs.fullCalendar.getApi().addEvent({ //等同于 this.calendarApi.addEventtitle: this.form.content,start: this.selectInfo.startStr,end: this.selectInfo.endStr,});}},// 增加事件addEvent() {this.form.content = '';this.dialogFormVisible = true;// this.monthEvent},//点击日历中的某一日程handleEventClick(clickInfo) {console.log('clickInfo:', clickInfo);// 用户点击事件时触发,用于编辑或删除事件const event = clickInfo.event;console.log('Clicked on:', event.title);// 这里可以弹出模态框进行编辑或调用删除函数等操作},// 单击事件(日历中的某一天)handleDateClick(e) {this.dayDate = e.dateStr;if (e.dateStr !== prev) {clickCount = 0;}clickCount += 1;prev = e.dateStr;setTimeout(() => {if (clickCount === 2) {console.log("db click");} else if (clickCount === 1) {console.log("one click");}clickCount = 0;}, 300);},// 切换prev() {this.calendarApi.prev();this.title = this.calendarApi.view.title;},next() {this.calendarApi.next();this.title = this.calendarApi.view.title;},// 今天today(date, jsEvent, view) {// if (this.type === "timeline") {// this.calendarApi.changeView("customTimeLineWeek");// } else {// this.calendarApi.changeView("customGridWeek");// }this.calendarApi.today();this.title = this.calendarApi.view.title;this.calendarApi.changeView("timeGridDay");// this.calendarApi.today();// this.title = this.calendarApi.view.title;},// 月month() {if (this.type === "timeline") {this.calendarApi.changeView("customTimeLineMonth");} else {this.calendarApi.changeView("dayGridMonth");}this.calendarApi.today();this.title = this.calendarApi.view.title;},// 周week() {if (this.type === "timeline") {this.calendarApi.changeView("customTimeLineWeek");} else {this.calendarApi.changeView("customGridWeek");}this.calendarApi.today();this.title = this.calendarApi.view.title;},// 天day() {this.calendarApi.today();this.title = this.calendarApi.view.title;},// 查询search() {this.calendarApi.changeView("dayGrid", {start: "2022-07-07",end: "2022-07-09",});},// 选择时间线、日程handleType() {if (this.type === "timeline") {this.calendarApi.changeView("customTimeLineMonth");this.calendarOptions.slotLabelFormat = null;} else {this.calendarApi.changeView("dayGridMonth");}},},};
</script>
<style scoped>.demo-app {display: flex;min-height: 100%;font-family: Arial, Helvetica Neue, Helvetica, sans-serif;font-size: 14px;}.demo-app-sidebar {width: 300px;line-height: 1.5;background: #eaf9ff;border-right: 1px solid #d3e2e8;}.demo-app-sidebar-section {padding: 2em;}.demo-app-main {flex-grow: 1;padding: 3em;}.fc {/* the calendar root */max-width: 1100px;margin: 0 auto;}.fc-toolbar {width: 100%;margin: 30px auto;display: flex;flex: 1;justify-content: space-around;align-content: center;}.fc-center {/* height: 40px; */display: flex;align-content: center;}.fc-center .title {font-size: 16px;padding: 0 15px;font-weight: 700;/* height: 40px; *//* line-height: 40px; */}
</style>
相关文章:

了解Vue中日历插件Fullcalendar
实现效果如下图: 月视图 周视图 日视图 官方文档地址:Vue Component - Docs | FullCalendar 1、安装与FullCalendar相关的依赖项 npm install --save fullcalendar/vue fullcalendar/core fullcalendar/daygrid fullcalendar/timegrid fullcalend…...

Cloudreve存储策略-通过从机存储来拓展容量
Sham的云服务器是搬瓦工最低低低配的,1H 0.5G不说,硬盘容量也只有10g,说实话,装了宝塔面板和服务器套件后,基本满了,这时又想在云服务器上打个网盘用于下载、存储,这时就需要拓展硬盘࿰…...

java进阶-jvm精讲及实战
深入了解jvm及实战 1.引言2.jvm概念理解 1.引言 jvm是深入了解java底层逻辑的必备知识储备,在中大型开发团队里,中高级工程师必须要了解和掌握,也是中高级工程师面试必考题,在实战中用于程序性能调优,内存泄露分析等 2.jvm概念理解...

vue中引入sass、scss
常规步骤 1. 创建项目 使用vue cli 脚手架工具创建项目 vue create xxxx2. 创建全局样式文件 全局样式变量 路径:/assets/styles/variables.scss //flex 布局变量 $--flex-direction: ("row", "column"); $--flex-position: ("start"…...

Java学习笔记(八)——Lambda表达式
文章目录 Lambda表达式Lambda表达式的省略写法Lambda练习练习1练习2 算法题算法题1 斐波那契数列算法题2 猴子吃桃子算法题3 爬楼梯 Lambda表达式 Lambda表达式是JDK8开始的一种新语法形式。 基本作用:简化函数式接口的匿名内部类的写法。 注意: Lam…...

【JavaEE】CAS
作者主页:paper jie_博客 本文作者:大家好,我是paper jie,感谢你阅读本文,欢迎一建三连哦。 本文于《JavaEE》专栏,本专栏是针对于大学生,编程小白精心打造的。笔者用重金(时间和精力)打造&…...

Linux 系统之部署 h5ai 目录列表程序
一、h5ai 介绍 1.1)h5ai 简介 h5ai 是用于 HTTP Web 服务器的现代文件索引器,专注于您的文件。目录以吸引人的方式显示,浏览它们通过不同的视图、面包屑和树概述得到增强。最初 h5ai 是 HTML5 Apache Index 的首字母缩写,但现在它…...

MySQL自增ID耗尽探究:分析与解决方案
MySQL自增ID耗尽探究:分析与解决方案 一、引言 在面试过程中,面试官抛出了一个看似简单却又深入的问题:“MySQL的自增ID用完了,怎么办?” 自增ID耗尽可能看似遥远,但在处理大量数据的系统中,…...

操作系统-操作系统引导(磁盘 操作系统引导过程)
文章目录 总览一个刚买来的磁盘(硬盘)往磁盘安装操作系统后操作系统引导过程例:windows操作系统的初始化程序 总览 一个刚买来的磁盘(硬盘) 此时空空如也 往磁盘安装操作系统后 操作系统在C盘 主引导记录不属于某…...

基于SpringBoot+Redis的前后端分离外卖项目-苍穹外卖微信小程序端(十三)
地址簿相关功能 1.1 需求分析和设计1.1.1 产品原型1.1.2 接口设计1.1.3 表设计 1.2 代码实现1.2.1 Mapper层1.2.2 Service层1.2.3 Controller层 1.1 需求分析和设计 1.1.1 产品原型 地址簿,指的是消费者用户的地址信息,用户登录成功后可以维护自己的地…...

SAP S/4HANA 2023 Fully-Activated Appliance 虚拟机版介绍
注:市面上所有在售虚拟机均为拷贝本人所作的虚拟机,存在各种技术问题,请知悉。 SAP S4HANA 2023 FAA版本内置了四个Client: 1、000:SAP初始Client,原则上不能动; 2、100:只激活了US…...

【Docker篇】详细讲解容器相关命令
🎊专栏【Docker】 🍔喜欢的诗句:更喜岷山千里雪 三军过后尽开颜。 🎆音乐分享【如愿】 🎄欢迎并且感谢大家指出小吉的问题🥰 文章目录 🛸容器🌹相关命令🍔案例⭐创建并运…...

LSTM学习笔记
上一篇文章中我们提到,CRNN模型中用于预测特征序列上下文的模块为双向LSTM模块,本篇中就来针对该模块的结构和实现做一些理解。 Bidirectional LSTM模块结构如下图所示: 在Pytorch中,已经集成了LSTM模块,定义如下&…...

Android 13.0 Recent列表不显示某个app
1.概述 在13.0 的系统产品rom定制化开发中,在点击导航栏最近任务列表时,如果做到不显示某个app 呢 一种做法是在app中直接处理 一种做法是在framework中处理 接下来看这两种处理方法 1, app中处理 为该应用AndroidManifest xml文件中主MainActivity设置属性 android:exclu…...

速盾网络:高防ip是什么
速盾网络:高防IP是什么 在当今信息化社会中,网络安全问题日益突出,各种网络攻击威胁层出不穷。为了保护企业的网络安全,提高网络业务的稳定性,高防IP应运而生。那么,什么是高防IP呢? 高防IP是…...

全志A133AndroidQ编译方式
编译uboot: cd longan/brandy/brandy-2.0 ./build.sh -p sun50iw10p1 //A133-android-10-plus\longan\brandy\brandy-2.0\u-boot-2018\u-boot.bin复制为u-boot-sun50iw10p1.bin 或者 //longan\brandy\brandy-2.0\u-boot-2018\configs\sun50iw10p1_defconfig cd …...

2024首更---Web Service 教程
Web Services 简介 Web Services 可使您的应用程序成为 Web 应用程序。 Web Services 通过 Web 进行发布、查找和使用。 您应当具备的基础知识 在继续学习之前,您需要对下面的知识有基本的了解: HTMLXML 如果您希望首先学习这些项目,请在…...

Day29- 贪心算法part03
一、K 次取反后最大化的数组和 题目一:1005. K 次取反后最大化的数组和 1005. K 次取反后最大化的数组和 给你一个整数数组 nums 和一个整数 k ,按以下方法修改该数组: 选择某个下标 i 并将 nums[i] 替换为 -nums[i] 。 重复这个过程恰…...

RPA与ChatGPT的融合:智能化流程的未来
RPA(Robotic Process Automation)是一种利用软件机器人模拟人类操作的技术,可以实现对各种业务流程的自动化执行。ChatGPT是一种基于深度学习的自然语言生成模型,可以根据给定的上下文生成流畅、连贯、有逻辑的文本。RPA与ChatGPT…...

Ubuntu安装maven并且配置阿里源
ubuntu环境搭建专栏🔗点击跳转 Ubuntu系统环境搭建(十二)——Ubuntu安装maven并且配置阿里源 文章目录 Ubuntu系统环境搭建(十二)——Ubuntu安装maven并且配置阿里源1.安装maven1.1更新源列表1.2安装1.3验证 2.配置阿…...

如何通过idea使用JDK8.0创建Spring项目
目前 IDEA 进行了优化,所以我们在创建 Spring 项目时会发现,以及不能选择通过 JDK8.0 创建了,这是因为官方已经不再提供 JDK8.0 创建 Spring 项目,我们可以通过修改创建 Spring 项目的路径来解决该问题 在创建 Spring 项目的页面&…...

Spark读取kafka(流式和批数据)
spark读取kafka(批数据处理) # 按照偏移量读取kafka数据 from pyspark.sql import SparkSessionss SparkSession.builder.getOrCreate()# spark读取kafka options {# 写kafka配置信息# 指定kafka的连接的broker服务节点信息kafka.bootstrap.servers: n…...

经典目标检测YOLO系列(二)YOLOV2的复现(1)总体网络架构及前向推理过程
经典目标检测YOLO系列(二)YOLOV2的复现(1)总体网络架构及前向推理过程 和之前实现的YOLOv1一样,根据《YOLO目标检测》(ISBN:9787115627094)一书,在不脱离YOLOv2的大部分核心理念的前提下,重构一款较新的YOLOv2检测器,来对YOLOV2有…...

怎样使用崭新的硬盘
新买的一块硬盘,接到电脑上,打开机器,却找不到新的硬盘,怎么回事?新的硬盘是坏的么?怎样才能把新硬盘用起来? 可能有几种原因导致您的电脑无法识别新的硬盘。以下是一些建议的解决方法ÿ…...

Kafka-多线程消费及分区设置
目录 一、Kafka是什么?消息系统:Publish/subscribe(发布/订阅者)模式相关术语 二、初步使用1.yml文件配置2.生产者类3.消费者类4.发送消息 三、减少分区数量1.停止业务服务进程2.停止kafka服务进程3.重新启动kafka服务4.重新启动业…...

计算机导论06-人机交互
文章目录 人机交互基础人机交互概述人机交互及其发展人机交互方式人机界面 新型人机交互技术显示屏技术跟踪与识别(技术)脑-机接口 多媒体技术多媒体技术基础多媒体的概念多媒体技术及其特性多媒体技术的应用多媒体技术发展趋势 多媒体应用技术文字&…...

hot100:07接雨水
题目链接: 力扣(LeetCode)官网 - 全球极客挚爱的技术成长平台 算法思想: 这里采取的是暴力解法和双指针的解法,但是这个题目还有其他的两种解法(单调栈和动态规划,同学可以自行了解ÿ…...

Docker安装MySQL教程分享(附MySQL基础入门教程)
docker安装MySQL Docker可以通过以下命令来安装MySQL容器: 首先确保已经在计算机上安装了Docker。如果没有安装,请根据操作系统的不同进行相应的安装。 打开终端或命令提示符,并运行以下命令拉取最新版本的MySQL镜像: docker pu…...

麒麟V10挂载iso,配置yum源
本文介绍yum 如何挂载本地镜像源 1) 拷贝镜像到本地 2) 执行以下命令: # mount -o loop 镜像路径及镜像名字 /mnt(或 media) 挂载前 挂载后 3) 进入/etc/yum.repos.d(yum.repos.d 是一个目录,该目录是分析 RPM 软件…...

《Linux C编程实战》笔记:信号的捕捉和处理
Linux系统中对信号的处理主要由signal和sigaction函数来完成,另外还会介绍一个函数pause,它可以用来响应任何信号,不过不做任何处理 signal函数 #include <signal.h> void (*signal(int signum, void (*handler)(int)))(int);可以分解…...