fullcalendar日程管理插件月份切换回调处理方案

作者:Q.E.D. 时间:2024-05-09 15:25:55 

fullcalendar 版本:v5.9.0

解决方案

fullcalendar next ,prev等切换月份的按钮是没有回调函数,要想由回调函数必须用customButtons(自定义按钮,官方文档),它能提供回调函数,然后再回调函数里通过调用

this.$refs.calendar.$options.calendar.next();或calendar.next();

去切换月份。

示例

核心代码

fullcalendar设置及渲染

var nowDate = new Date();
var nowDateStr = nowDate.Format("yyyy-MM-dd");
var option = {
 initialDate: nowDateStr,
 // 默认周日作为第一天
 // firstDay: 1,
 // 日历中的日程是否可以编辑. 可编辑是指可以移动, 改变大小等
 editable: false,
 dayMaxEvents: true,
 // 允许天/周名称是否可点击,包括周次weekNumber,点击之后可以跳转到对于的天/周视图,默认false
 navLinks: false,
 dateClick: dateClick,
 // 自定义按钮
 customButtons: {
   prevYearCustom: {
     text: '上一年',
     click: function() {
       prevYearCustomClick();
     }
   },
   prevMonthCustom: {
     text: '上月',
     click: function() {
       prevMonthCustomClick();
     }
   },
   nextMonthCustom: {
     text: '下月',
     click: function() {
       nextMonthCustomClick();
     }
   },
   nextYearCustom: {
     text: '下一年',
     click: function() {
       nextYearCustomClick();
     }
   },
   todayCustom: {
     text: '今天',
     click: function() {
       todayCustomClick();
     }
   }
 },
 // 头部按钮布局展示设置
 headerToolbar: {
   right: 'prevYearCustom,prevMonthCustom,nextMonthCustom,nextYearCustom todayCustom',
 },
 events: [
 ]
};
var calendar = fullcalendar.initCalendar("calendar",option);

点击事件定义

// 日期点击事件
function dateClick(info){
 console.log(info);
}
// 上一年点击
function prevYearCustomClick(){
 calendar.prevYear();
 renderCalendar();
}
// 上月点击
function prevMonthCustomClick(){
 calendar.prev();
 renderCalendar();
}
// 下月点击
function nextMonthCustomClick(){
 calendar.next();
 renderCalendar();
}
// 下一年点击
function nextYearCustomClick(){
 calendar.nextYear();
 renderCalendar();
}
// 今日点击
function todayCustomClick(){
 calendar.today();
 renderCalendar();
}
// 刷新Calendar的数据
function renderCalendar(){
 // TODO:调用接口获取数据,这里定义为空数组
 var events=[];
 calendar.setOption('events', events);
}

展示效果

fullcalendar日程管理插件月份切换回调处理方案

注意:

fullcalendar events日程数据源的start和end 分别对应开始日期和结束日期,如果开始日期和结束日期是同一天的那么在@eventClick回调参数中end是默认为null的

fullcalendar日程管理插件月份切换回调处理方案

来源:https://blog.csdn.net/qq_34272760/article/details/120562510

标签:fullcalendar,插件,日程管理,月份回调
0
投稿

猜你喜欢

  • Python基础 括号()[]{}的详解

    2023-07-22 07:35:39
  • Bootstrap轮播插件简单使用方法介绍

    2024-04-27 15:19:06
  • 如何使用Python读取xml文件

    2022-09-16 16:37:51
  • Mysql 5.7 新特性之 json 类型的增删改查操作和用法

    2024-01-24 23:45:53
  • Python字典遍历的陷阱

    2022-11-16 21:59:11
  • 浅谈javascript:两种注释,声明变量,定义函数

    2024-04-16 09:06:06
  • flask route对协议作用及设计思路

    2023-01-19 13:21:34
  • 如何远程连接SQL Server数据库

    2009-06-08 12:41:00
  • python实现log日志的示例代码

    2023-11-29 13:25:49
  • 带你学习MySQL执行计划

    2024-01-18 12:34:37
  • 避免Adodb.Stream输出UTF-8时自动写入的BOM(asp)

    2011-08-24 20:32:56
  • python获取当前运行函数名称的方法实例代码

    2023-03-06 15:34:22
  • 解决Keras中Embedding层masking与Concatenate层不可调和的问题

    2022-06-02 17:02:16
  • django-rest-framework解析请求参数过程详解

    2023-03-26 18:18:00
  • JavaScript 数组方法filter与reduce

    2024-04-29 13:14:38
  • python递归函数求n的阶乘,优缺点及递归次数设置方式

    2022-12-08 16:17:08
  • vue学习教程之带你一步步详细解析vue-cli

    2024-05-09 10:52:46
  • pyqt实现.ui文件批量转换为对应.py文件脚本

    2022-01-22 03:32:26
  • MySQL执行外部sql脚本文件的命令

    2024-01-20 11:13:49
  • Python 中的 global 标识对变量作用域的影响

    2021-11-24 00:16:47
  • asp之家 网络编程 m.aspxhome.com