Vue3中如何使用fullcalendar日歷插件
npm install @fullcalendar/core npm install @fullcalendar/vue3 vue文件中引用 import FullCalendar from "@fullcalendar/vue3" 必須安裝一個(gè): npm install @fullcalendar/daygrid npm install @fullcalendar/multimonth npm install @fullcalendar/timegrid
在vue文件中的template中
<FullCalendar v-if="calendarOptions" style="margin-top: 30px" class="calenderCon" ref="fullCalendar" :options="calendarOptions" > </FullCalendar>
import resourceTimelinePlugin from "@fullcalendar/resource-timeline";// 引入需要的視圖 let calendarOptions = ref(); // 使用resourceTimelineMonth需安裝 onMounted(() => { calendarOptions.value = { plugins: [dayGridPlugin, timeGridPlugin, resourceTimelinePlugin], initialView: "resourceTimelineMonth", // 默認(rèn)為那個(gè)視圖(月:dayGridMonth,周:timeGridWeek,日:timeGridDay) headerToolbar: { left: "prev", center: "title", right: "today,next", }, locale: "zh-cn", // 切換語(yǔ)言,當(dāng)前為中文 eventColor: "#ffffff", // 全部日歷日程背景色 initialDate: proxy.$dayjs().format("YYYY-MM-DD"), // 自定義設(shè)置背景顏色時(shí)一定要初始化日期時(shí)間 allDaySlot: false, height: "422px", buttonText: { today: "當(dāng)前月", day: "日", }, // 日程 businessHours: { daysOfWeek: [1, 2, 3, 4], // Monday - Thursday startTime: "10:00", // a start time (10am in this example) endTime: "18:00", // an end time (6pm in this example) }, // 強(qiáng)調(diào)日歷上的特定時(shí)間段。默認(rèn)為周一至周五,上午9點(diǎn)至下午5點(diǎn)。 selectConstraint: { daysOfWeek: [1, 2, 3, 4], // Monday - Thursday startTime: "10:00", // a start time (10am in this example) endTime: "18:00", // an end time (6pm in this example) }, // 限制用戶選擇特定的時(shí)間窗口。 // 事件 // eventClick: eventClick, // 點(diǎn)擊日歷日程事件 // eventDrop: eventDrop, // 拖動(dòng)日歷日程事件 // eventResize: eventResize, // 修改日歷日程大小事件 // select: handleDateSelect, // 選中日歷格事件 // eventDidMount: this.eventDidMount, // 安裝提示事件 // loading: loading, // 視圖數(shù)據(jù)加載中、加載完成觸發(fā)(用于配合顯示/隱藏加載指示器。) // selectAllow: selectAllow, //編程控制用戶可以選擇的地方,返回true則表示可選擇,false表示不可選擇 // eventMouseEnter: eventMouseEnter, // 鼠標(biāo)滑過(guò) editable: true, // 是否可以進(jìn)行(拖動(dòng)、縮放)修改 eventStartEditable: true, // Event日程開(kāi)始時(shí)間可以改變,默認(rèn)true,如果是false其實(shí)就是指日程塊不能隨意拖動(dòng),只能上下拉伸改變他的endTime eventDurationEditable: true, // Event日程的開(kāi)始結(jié)束時(shí)間距離是否可以改變,默認(rèn)true,如果是false則表示開(kāi)始結(jié)束時(shí)間范圍不能拉伸,只能拖拽 selectable: true, // 是否可以選中日歷格 selectMinDistance: 0, // 選中日歷格的最小距離 dayMaxEvents: true, weekends: true, // 是否在任何日歷視圖中包括周六/周日列。 navLinks: false, // 確定日名和周名是否可單擊 schedulerLicenseKey: "GPL-My-Project-Is-Open-Source", // 此配置是為了消除右下角的版權(quán)提示 slotEventOverlap: false, // 相同時(shí)間段的多個(gè)日程視覺(jué)上是否允許重疊,默認(rèn)true允許 resourceAreaColumns: [ { headerContent: "車型", field: "room_name", }, { headerContent: "車牌", field: "car_code", }, ], resourceAreaWidth: "15%", resources: resourcesData.value, // 后臺(tái)給 渲染的數(shù)據(jù) events: matchList.value,// 后臺(tái)給 渲染的數(shù)據(jù) }; }) 數(shù)據(jù)格式(根據(jù)實(shí)際情況來(lái),均為后臺(tái)返回): resourcesData.value { id: item.id, room_name: item.car_type, car_code: item.car_code, } matchList.value { id: item.id, resourceId: item.id, title: "用車人:" + item.use_person_name + " 用車時(shí)間:" + item.start_time + "~" + item.end_time + "用途:" + item.purpose, start: item.start_time, end: item.end_time, color: "yellow", textColor: "black", }
文檔內(nèi)容比較豐富,可以自行去官網(wǎng)查看
附:官網(wǎng)地址:https://fullcalendar.io/
到此這篇關(guān)于Vue3使用fullcalendar日歷插件的文章就介紹到這了,更多相關(guān)Vue3 fullcalendar日歷插件內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
vue3 Teleport瞬間移動(dòng)函數(shù)使用方法詳解
這篇文章主要為大家詳細(xì)介紹了vue3 Teleport瞬間移動(dòng)函數(shù)使用方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-03-03Vue中使用JsonView來(lái)展示Json樹(shù)的實(shí)例代碼
這篇文章主要介紹了Vue之使用JsonView來(lái)展示Json樹(shù)的實(shí)例代碼,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11vue實(shí)現(xiàn)評(píng)價(jià)星星功能
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)評(píng)價(jià)星星功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-06-06vue使用Luckysheet插件實(shí)現(xiàn)excel導(dǎo)入導(dǎo)出
本文主要介紹了vue使用Luckysheet插件實(shí)現(xiàn)excel導(dǎo)入導(dǎo)出,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2024-03-03vue?+?element-ui?季度選擇器組件?el-quarter-picker示例詳解
本文介紹如何在Vue項(xiàng)目中使用基于Element-UI的季度選擇器組件ElQuarterPicker,通過(guò)引用并調(diào)用ElQuarterPicker.vue組件來(lái)實(shí)現(xiàn)季度選擇功能,感興趣的朋友跟隨小編一起看看吧2024-09-09如何解決element-ui中多個(gè)table在tab切換時(shí)出現(xiàn)寬度縮小問(wèn)題
這篇文章主要介紹了如何解決element-ui中多個(gè)table在tab切換時(shí)出現(xiàn)寬度縮小問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10