当前位置: 首页 > news >正文

@fullcalendar/vue 日历组件

功能:日程安排,展示日历,可以用来做会议日历,可以跨日期显示日程。

Fullcalendar+vue3 日历组件
参考文档:【vue2】一个完整的日历组件 fullcalendar,会议预约功能
中文说明文档:https://www.helloweba.net/javascript/454.html#fc-EventObject

效果图:

在这里插入图片描述

安装插件:

"@fullcalendar/core": "^6.1.15","@fullcalendar/daygrid": "^6.1.15","@fullcalendar/interaction": "^6.1.15","@fullcalendar/list": "^6.1.15","@fullcalendar/resource-timeline": "^6.1.15","@fullcalendar/timegrid": "^6.1.15","@fullcalendar/vue3": "^6.1.15",  // 注意!!!vue2是@fullcalendar/vue"@tinymce/tinymce-vue": "^6.0.1",

实现代码(VUE2):

一个实现Tooltip效果的插件(因为日历组件的title只能是单行,想展示更多信息会有局限。所以采用tooltip的方式来解决):

npm --save install tippy.js
<FullCalendar class="fullCalendar" ref="fullCalendar" :options="calendarOptions" />import FullCalendar from "@fullcalendar/vue";
import interactionPlugin from "@fullcalendar/interaction";
import timeGridPlugin from "@fullcalendar/timegrid";//实现Tooltip效果的插件
import tippy from 'tippy.js' //引入 tippy.js
import 'tippy.js/dist/tippy.css' //引入 tippy.js
import 'tippy.js/themes/light.css' //引入主题
import 'tippy.js/animations/scale.css'let startdate = 0 // view显示区域开始时间
let endDate = 0 // view视图显示区域结束时间
let initialDate = new Date()
export default {components: {FullCalendar },data() {return {calendarApi: null,calendarOptions: {plugins: [interactionPlugin, timeGridPlugin], // 需要用哪个插件引入后放到这个数组里initialDate: initialDate, // 日历第一次加载时显示的初始日期。可以解析为Date的任何值包括ISO8601日期字符串,例如"2014-02-01"。initialView: 'timeGridWeek', // 日历加载时的初始视图,默认值为'dayGridMonth',可以为任何可用视图的值,如例如'dayGridWeek','timeGridDay','listWeek'locale: 'zh-cn', // 设置日历的语言,中文为 “zh-cn”// firstDay: '1', // 设置每周的第一天,默认值取决于当前语言环境,该值为代表星期几的数字,且值必须为整数,星期日=0// weekNumberCalculation: 'ISO', // 指定"ISO"结果为ISO8601周数。指定"ISO"将firstDay的默认值更改为1(Monday)allDaySlot: false,slotMinTime: '06:00:00',slotMaxTime: '24:00:00',expandRows: true,firstDay: '1',header: false,views: {timeGridWeek: {type: 'timeGridWeek',duration: { weeks: 1 }}},customButtons: {refreshButton: {text: '今天',// icon: 'el-icon-refresh-right',// color:'red',backgroundColor: 'yellow',click: this.handleRefetchEvents},next: {click: this.nextClick},prev: {click: this.prevClick}},headerToolbar: {left: 'prev,next,refreshButton',center: '',right: ''},buttonIcons: {prev: 'chevron-left',next: 'chevron-right'},events: [{title: 'All Day Event',start: '2023-3-08',end: '2023-3-10',color: 'red',textColor: 'white',allDay: true}], // 将在日历上显示的事件对象, events 可以是数组、json、函数。具体可以查看官方文档eventResize: this.eventResize, // 修改日历日程大小事件eventClick: this.handleDateClick, // 点击事件时,触发该回调// eventMouseLeave: this.handleMouseLeave, // 鼠标移除时,触发该回调eventMouseEnter: this.handleEventMouseEnter, // 鼠标悬停在事件上时,触发该回调dateClick: this.handleDateClick, // 当用户单击日期或时间时,触发该回调,触发此回调,您必须加载interaction插件datesSet: this.handleDateSet, // 获取view视图显示时间select: this.handleDateSelect, // 选中日历格事件selectable: true // 是否可以选中日历格}};},computed: {},watch: {},mounted() {this.calendarApi = this.$refs.fullCalendar.getApi()},methods: {handleEventMouseEnter(info) {tippy(info.el, {appendTo: document.body,// content: info.event.extendedProps.username,content: "<div style='z-index:9999999'>地点重复</div>",// theme:'light',placement: 'top',arrow: true,allowHTML: true,// 鼠标放在提示中提示不消失interactive: true})},// 刷新handleRefetchEvents(mouseEvent, htmlElement) {this.refreshCalendar(initialDate)this.calendarApi.render()},refreshCalendar(newDateTime) {initialDate = newDateTime // 更新绑定的时间数据if (this.$refs.fullCalendar.getApi()) {this.calendarApi.gotoDate(newDateTime)}},nextClick(mouseEvent, htmlElement) {this.calendarApi.next()},prevClick(mouseEvent, htmlElement) {this.calendarApi.prev()},eventResize(eventResizeInfo) {const publicId = eventResizeInfo.event._def.publicId},// 点击事件handleDateClick(dateClickInfo, event) {let selectedBase = {start: dateClickInfo.event._instance.range.start,end: dateClickInfo.event._instance.range.end,publicId: dateClickInfo.event._def.publicId,title: dateClickInfo.event._def.title,backgroundColor: dateClickInfo.event._def.ui.backgroundColor,borderColor: dateClickInfo.event._def.ui.borderColor}const publicId = dateClickInfo.event._def.publicId},// 获取视图区域展示时间--开始日期、结束日期handleDateSet(datesSetInfo) {startdate = moment(datesSetInfo.startStr).unix()endDate = moment(datesSetInfo.endStr).unix()},handleDateSelect(dateClickInfo, event) { },},created() {},beforeCreate() {},beforeMount() {},beforeUpdate() {},updated() {},beforeDestroy() {},destroyed() {},activated() {},
}
http://www.lryc.cn/news/591427.html

相关文章:

  • SpringCloud面试笔记
  • 【每日刷题】跳跃游戏
  • Apache DolphinScheduler介绍与部署
  • 分布式光伏发电系统中的“四可”指的是什么?
  • 解读PLM系统软件在制造企业研发管理中的应用
  • 18650锂电池点焊机:新能源制造的精密纽带
  • AR智能巡检:制造业零缺陷安装的“数字监工”
  • Git仓库核心概念与工作流程详解:从入门到精通
  • 【java面试day6】redis缓存-数据淘汰策略
  • 二刷 黑马点评 秒杀优化
  • 全面升级!WizTelemetry 可观测平台 2.0 深度解析:打造云原生时代的智能可观测平台
  • Netty-基础知识
  • 【前端如何利用 localStorage 存储 Token 及跨域问题解决方案】
  • 7.17 Java基础 | 集合框架(下)
  • 【unitrix】 6.5 基础整数类型特征(base_int.rs)
  • 对比分析:给数据找个 “参照物”,让孤立数字变 “决策依据”
  • 数据呈现进阶:漏斗图与雷达图的实战指南
  • SQLite的可视化界面软件的安装
  • H3CNE 综合实验二解析与实施指南
  • 医院各类不良事件上报,PHP+vscode+vue2+element+laravel8+mysql5.7不良事件管理系统源代码,成品源码,不良事件管理系统
  • ASP .NET Core 8实现实时Web功能
  • linux-SSH
  • Django由于数据库版本原因导致数据库迁移失败解决办法
  • 从C#6天学会Python:速通基础语法(第一天)
  • C#监听txt文档获取新数据
  • [IRF/Stack]华为/新华三交换机堆叠配置
  • 虚拟化测试工具Parasoft Virtualize如何为汽车企业提供仿真测试?
  • C语言模拟面向对象三大特性与C++实现对比
  • Python 网络爬虫 —— 提交信息到网页
  • Hyperledger Fabric:构建企业区块链网络的实践指南