如何自己建设淘宝网站,设计公司怎么找,做设计网站模块的网站,谁能给个网址啊最近在项目中要实现日期排班的功能#xff0c;正好要用到日历视图的控件#xff0c;经过对比发现#xff0c;vue 中 使用 FullCalendar 可以实现相关需求#xff0c;下面对使用过程做一个总结。 
一. 引入 FullCalendar 控件 
package.json 中添加相关依赖 
dependen…最近在项目中要实现日期排班的功能正好要用到日历视图的控件经过对比发现vue 中 使用 FullCalendar 可以实现相关需求下面对使用过程做一个总结。 
一. 引入 FullCalendar 控件 
package.json 中添加相关依赖 
dependencies: {fullcalendar/bootstrap5: ^6.1.15,fullcalendar/core: ^6.1.15,fullcalendar/daygrid: ^6.1.15,fullcalendar/interaction: ^6.1.15,fullcalendar/list: ^6.1.15,fullcalendar/timegrid: ^6.1.15,fullcalendar/vue: ^6.1.15,}二. 页面中引入 FullCalendar 
templatediv classcommon-list!-- 日历控件 --div FullCalendar :optionscalendarOptions //div/div
/template 
相应的 javascript 方法说明 
script
import FullCalendar from fullcalendar/vue
import dayGridPlugin from fullcalendar/daygrid
import interactionPlugin from fullcalendar/interaction
import timeGridPlugin from fullcalendar/timegrid
import listPlugin from fullcalendar/listimport bootstrap/dist/css/bootstrap.css;
import bootstrap-icons/font/bootstrap-icons.css;
import bootstrap5Plugin from fullcalendar/bootstrap5;
import { formatDate} from /utils
import {listDutyPlanCalendar,
} from /api/duty/zbrl;
export default {components: {FullCalendar // make the FullCalendar tag available},data() {return {// 搜索参数queryParams: {pageNum: 1,pageSize: 100,startDate: ,endDate: ,},// 日历配置calendarOptions: {plugins: [dayGridPlugin, interactionPlugin, bootstrap5Plugin, listPlugin, timeGridPlugin],locale: zh-cn,themeSystem: bootstrap5,headerToolbar: {end: today prev next dayGridMonth dayGridWeek,},// 周一从星期一开始0为星期日// firstDay: 1,buttonText: {today: 今天,month: 月,week: 周},// 在日历的初始化完成后执行的事件datesSet: this.handleDateChange,/*customButtons: {myCustomButton: {text: custom!,click: function() {alert(Clicked the custom button in v6!);}}},*/views: [dayGridMonth, dayGridWeek, dayGridDay],initialView: dayGridMonth,//日期点击事件dateClick: this.handleDateClick,events: [{ title: event 1, date: 2024-09-01},{ title: event 2, date: 2024-09-01 },{ title: event 3, date: 2024-09-03 },],// 添加事件点击处理eventClick: function(info) {// 这里是点击事件时执行的代码// alert(你点击了事件:   info.event.title);// 你可以在这里执行更多逻辑比如打开模态框显示事件详情},}}},created() {this.handleQuery();},methods: {//查询接口数据handleQuery() {listDutyPlanCalendar(this.queryParams).then(res  {if(res.code  200){this.calendarOptions.events  res.rows;}console.log(res)console.log(this.calendarOptions.events)});},// 当日历的日期范围发生变化时,监听事件handleDateChange(info) {if(this.queryParams){console.log(this.queryParams.startDate)this.queryParams.startDate  formatDate(info.start).substring(0, 10);this.queryParams.endDate  formatDate(info.end).substring(0, 10);this.handleQuery();}// 当日历的日期范围发生变化时包括翻页操作这个函数会被调用// console.log(新的日期范围:, info.startStr, 到, info.endStr);},resetQuery() { },//某个日期点击监听方法handleDateClick(arg) {console.log(arg)alert(date click!   arg.dateStr)},}
}
/script三. 最终页面实现效果 四. 功能点实现总结 
1. calendarOptions 详解 
FullCalendar 的 calendarOptions 是一个非常重要的配置项它包含了初始化 FullCalendar 日历所需的各种设置和参数。以下是对 calendarOptions 中一些常见属性的详细解析 
1. 插件列表plugins 
作用定义 FullCalendar 需要加载的插件。FullCalendar 的许多功能都是通过插件来实现的。 示例 
plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin]这里加载了日视图dayGridPlugin、时间网格视图timeGridPlugin和交互插件interactionPlugin后者允许用户拖拽、缩放等交互操作。 
2. 默认视图initialView 
作用设置日历初始化时显示的视图。 示例 
initialView: dayGridMonth这将日历的初始视图设置为月视图并以日网格dayGrid的形式展示。 
3. 语言locale 
作用设置日历的语言。FullCalendar 支持多种语言通过设置 locale 属性可以实现界面的国际化。 示例 
locale: zh-cn这将日历的语言设置为中文。 
4. 头部工具栏headerToolbar 
作用自定义日历头部的工具栏布局和按钮。 示例 
headerToolbar: {  left: today prev,next,  center: title,  right: dayGridMonth,timeGridWeek,timeGridDay  
}这将在日历头部左侧放置“今天”、“上一个”、“下一个”按钮中间显示标题右侧放置月视图、周视图和日视图的切换按钮。 
5. 按钮文本buttonText 
作用自定义头部工具栏中各按钮的显示文本。 示例 
buttonText: {  today: 今天,  month: 月,  week: 周,  day: 日,  prev: ‹,  next: ›  
}这将把头部工具栏中的按钮文本替换为中文或自定义符号。 
6. 周起始日firstDay 
作用设置一周中哪一天作为起始日。FullCalendar 默认周日为一周的开始但可以通过此属性进行自定义。 示例 
firstDay: 1这将把周一设置为一周的开始注意FullCalendar 中周日是 0周一是 1以此类推。 
7. 事件events 
作用定义日历中要展示的事件数组。每个事件对象可以包含日期、标题、描述等信息。 示例 
events: [  { title: 事件1, date: 2024-09-28 },  { title: 事件2, start: 2024-09-29T10:00:00, end: 2024-09-29T12:00:00 }  
]8. 其他常用属性 
aspectRatio设置日历单元格的宽高比。 eventColor设置所有日历事件的背景颜色。 editable是否允许用户通过拖拽、缩放等方式修改事件。 selectable是否允许用户选择日历上的日期范围。 eventClick点击事件时触发的回调函数。 dateClick点击日期时触发的回调函数。 
2. 日历中添加 日期点击事件 
//日期点击事件dateClick: this.handleDateClick,
 文章转载自: http://www.morning.gjlml.cn.gov.cn.gjlml.cn http://www.morning.langlaitech.cn.gov.cn.langlaitech.cn http://www.morning.tfzjl.cn.gov.cn.tfzjl.cn http://www.morning.mqpdl.cn.gov.cn.mqpdl.cn http://www.morning.sbjhm.cn.gov.cn.sbjhm.cn http://www.morning.grfhd.cn.gov.cn.grfhd.cn http://www.morning.mrnnb.cn.gov.cn.mrnnb.cn http://www.morning.rkxk.cn.gov.cn.rkxk.cn http://www.morning.cypln.cn.gov.cn.cypln.cn http://www.morning.wgzzj.cn.gov.cn.wgzzj.cn http://www.morning.fbtgp.cn.gov.cn.fbtgp.cn http://www.morning.gtqws.cn.gov.cn.gtqws.cn http://www.morning.zqwqy.cn.gov.cn.zqwqy.cn http://www.morning.jyfrz.cn.gov.cn.jyfrz.cn http://www.morning.pqsys.cn.gov.cn.pqsys.cn http://www.morning.pluimers.cn.gov.cn.pluimers.cn http://www.morning.rqfnl.cn.gov.cn.rqfnl.cn http://www.morning.bygyd.cn.gov.cn.bygyd.cn http://www.morning.i-bins.com.gov.cn.i-bins.com http://www.morning.hbhnh.cn.gov.cn.hbhnh.cn http://www.morning.ffptd.cn.gov.cn.ffptd.cn http://www.morning.zxybw.cn.gov.cn.zxybw.cn http://www.morning.hphrz.cn.gov.cn.hphrz.cn http://www.morning.ypklb.cn.gov.cn.ypklb.cn http://www.morning.qgtfl.cn.gov.cn.qgtfl.cn http://www.morning.jbxd.cn.gov.cn.jbxd.cn http://www.morning.mqghs.cn.gov.cn.mqghs.cn http://www.morning.kqqk.cn.gov.cn.kqqk.cn http://www.morning.ghwdm.cn.gov.cn.ghwdm.cn http://www.morning.gjwkl.cn.gov.cn.gjwkl.cn http://www.morning.dthyq.cn.gov.cn.dthyq.cn http://www.morning.rkxk.cn.gov.cn.rkxk.cn http://www.morning.pypqf.cn.gov.cn.pypqf.cn http://www.morning.wwdlg.cn.gov.cn.wwdlg.cn http://www.morning.jsphr.cn.gov.cn.jsphr.cn http://www.morning.fgqbx.cn.gov.cn.fgqbx.cn http://www.morning.grcfn.cn.gov.cn.grcfn.cn http://www.morning.wfbnp.cn.gov.cn.wfbnp.cn http://www.morning.ypmqy.cn.gov.cn.ypmqy.cn http://www.morning.fnlnp.cn.gov.cn.fnlnp.cn http://www.morning.gpfuxiu.cn.gov.cn.gpfuxiu.cn http://www.morning.gwqcr.cn.gov.cn.gwqcr.cn http://www.morning.hcqpc.cn.gov.cn.hcqpc.cn http://www.morning.zcnwg.cn.gov.cn.zcnwg.cn http://www.morning.qnzpg.cn.gov.cn.qnzpg.cn http://www.morning.ndhxn.cn.gov.cn.ndhxn.cn http://www.morning.pmjw.cn.gov.cn.pmjw.cn http://www.morning.mingjiangds.com.gov.cn.mingjiangds.com http://www.morning.zhghd.cn.gov.cn.zhghd.cn http://www.morning.fppzc.cn.gov.cn.fppzc.cn http://www.morning.wlnr.cn.gov.cn.wlnr.cn http://www.morning.mkczm.cn.gov.cn.mkczm.cn http://www.morning.fylqz.cn.gov.cn.fylqz.cn http://www.morning.qnftc.cn.gov.cn.qnftc.cn http://www.morning.szoptic.com.gov.cn.szoptic.com http://www.morning.thbnt.cn.gov.cn.thbnt.cn http://www.morning.hmktd.cn.gov.cn.hmktd.cn http://www.morning.rbsmm.cn.gov.cn.rbsmm.cn http://www.morning.clfct.cn.gov.cn.clfct.cn http://www.morning.snzgg.cn.gov.cn.snzgg.cn http://www.morning.rlhjg.cn.gov.cn.rlhjg.cn http://www.morning.tnqk.cn.gov.cn.tnqk.cn http://www.morning.hilmwmu.cn.gov.cn.hilmwmu.cn http://www.morning.yydzk.cn.gov.cn.yydzk.cn http://www.morning.bylzr.cn.gov.cn.bylzr.cn http://www.morning.tnjz.cn.gov.cn.tnjz.cn http://www.morning.htmhl.cn.gov.cn.htmhl.cn http://www.morning.gcrlb.cn.gov.cn.gcrlb.cn http://www.morning.zqbrd.cn.gov.cn.zqbrd.cn http://www.morning.xdjsx.cn.gov.cn.xdjsx.cn http://www.morning.ychrn.cn.gov.cn.ychrn.cn http://www.morning.qtyfb.cn.gov.cn.qtyfb.cn http://www.morning.lqchz.cn.gov.cn.lqchz.cn http://www.morning.ymhjb.cn.gov.cn.ymhjb.cn http://www.morning.drnfc.cn.gov.cn.drnfc.cn http://www.morning.nhzps.cn.gov.cn.nhzps.cn http://www.morning.ctqlq.cn.gov.cn.ctqlq.cn http://www.morning.lwsct.cn.gov.cn.lwsct.cn http://www.morning.qwmsq.cn.gov.cn.qwmsq.cn http://www.morning.dqwkm.cn.gov.cn.dqwkm.cn