Vue.js搭配Laravel使用FullCalendar时月、周视图按钮不显示问题
FullCalendar视图切换按钮不显示解决方法
1. 安装对应视图插件
FullCalendar的dayGrid、timeGrid视图属于独立插件,需要单独安装依赖:
npm install @fullcalendar/daygrid @fullcalendar/timegrid
2. 引入并注册插件
Vue版本的FullCalendar需要显式注册用到的插件才能激活对应功能,同时注意版本配置差异:
- FullCalendar v5及以上版本,原
header配置已更名为headerToolbar - v4及以下版本保留
header配置即可
修正后完整代码
<template> <full-calendar ref="fullCalendar" :events="calendarEvents" :allDaySlot="false" :height="1000" :plugins="calendarPlugins" <!-- v5+版本用headerToolbar,v4及以下替换为header即可 --> :headerToolbar="{ left: 'prev, next today', center: 'title', right: 'dayGridMonth,dayGridWeek,timeGridDay' }" > </full-calendar> </template> <script> // 引入所需插件 import dayGridPlugin from '@fullcalendar/daygrid' import timeGridPlugin from '@fullcalendar/timegrid' export default { data() { return { // 注册插件 calendarPlugins: [dayGridPlugin, timeGridPlugin], calendarEvents: [{ events(start, end, timezone, callback) { axios.get('http://localhost:8000/show-events').then(res => { callback(res.data.eventList) }) }, color: 'blue', textColor: 'white', }] } } } </script>
内容的提问来源于stack exchange,提问作者Arthur
相关产品推荐
相关产品推荐

