fullcalendar动态获取数据

fullcalendar动态获取数据,包含上一个下一个  周视图 月视图

我知道的三种绑定数据的方式:

1.直接赋值一个数组[]

2.使用url,它会自动加上start和end参数

1
events: "/api/demo-feeds/events.json?overload-day"

3.使用方法包装

 

 


const getDatas = async (val) => {
  return await getXxxs(val)
/**打印val:
  1. end: Sun Sep 03 2023 00:00:00 GMT+0800 (China Standard Time) {}
  2. endStr: "2023-09-03T00:00:00+08:00"
  3. start: Sun Aug 27 2023 00:00:00 GMT+0800 (China Standard Time) {}
  4. startStr: "2023-08-27T00:00:00+08:00"
  5. timeZone: "local"
**/
}
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const calendarOptions = ref({
  plugins: [dayGridPlugin, interactionPlugin, timeGridPlugin],
  initialView: 'timeGridWeek',
  eventMouseEnter: handleEventMouseEnter,
  eventClick: handleEventClick,
  locale: zhCnLocale,
  weekends: true,
  firstDay: 0,
  headerToolbar: {
    // 头部toolba
    left: 'prev,next today',
    center: 'title',
    right: 'timeGridDay,timeGridWeek,dayGridMonth'
    // right: 'dayGridMonth'
  },
  events: getDatas
  //  [
  //   //日程事件的json
  //   // { title: 'event 1', color: '#409eff;', date: '2023-08-14 12:00:00' },
  //   // { title: 'event 2', color: '#67c23a', date: '2023-08-15 05:59:23' },
  //   // { title: 'event 3', color: '#e6a23c', date: '2023-08-16 08:23:00' }
  // ]
})<br><br>

  参考:https://www.cnblogs.com/ichenchao/articles/12895462.html

 

Event Source Object

"event source"是Fullcalendar的事件数据源events,可以是你定义的一个数组,一个函数,一个返回json的接口,或者google calendar。

posted @   一个土豆一棵青菜  阅读(447)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
点击右上角即可分享
微信分享提示