VUE使用 FullCalendar 5.0 写日程安排

2 篇文章 0 订阅
1 篇文章 0 订阅

最近要写个日程排课的业务,找到了FullCalendar的日期处理。网上的大部分都是老版本,试出了一堆的坑,看着文档,慢慢的敲出个大概。我写的这些如果帮不了你,你还是去看下文档,虽然是英文的,带能解除大部分的问题。FullCalendar文档地址

贴一张效果图,如果和你的需求不一样,那就没办法了。
效果图
首先是安装插件

npm install --save @fullcalendar/vue @fullcalendar/daygrid

然后引入

<script>
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import interactionPlugin from '@fullcalendar/interaction'

export default {
  components: {
    FullCalendar // make the <FullCalendar> tag available
  },
  data() {
    return {
      calendarOptions: {
        plugins: [ dayGridPlugin, interactionPlugin ],
        initialView: 'dayGridMonth'
      }
    }
  }
}
</script>
<template>
  <FullCalendar :options="calendarOptions" />
</template>

这里是月日历,要改成周日历的话,需要安装

npm install --save @fullcalendar/timegrid

然后引入,(不一步一步的来了,其他的都配置上的区别了)

<script>
import FullCalendar from '@fullcalendar/vue'
// import dayGridPlugin from '@fullcalendar/daygrid'
import interactionPlugin from '@fullcalendar/interaction'
import timeGridPlugin from "@fullcalendar/timegrid";
export default {
  components: {
    FullCalendar // make the <FullCalendar> tag available
  },
  data() {
    return {
      calendarOptions: {
      	initialDate:new Date()//控制指定显示日期
        plugins: [ timeGridPlugin, interactionPlugin ],
        initialView: 'timeGridWeek'
        locale: "zh",//中文
        slotMinTime:'09:00',//展示时间
        slotMaxTime:'18:00',//展示时间
        dateClick: this.addEvent,//点击日历个空白触发事件
        eventClick: this.editEvent,//点击event触发事件
        events: [{
	        title:"",
			start:"",
			end:"",
			id:""
		}],//日程
      }
    }
  },
  methods:{
  	addEvent(info) {
      console.log(info)
    },
    editEvent(info) {
      console.log(info)
    },
  }
}
</script>
<template>
  <FullCalendar :options="calendarOptions" />
</template>

如果要对events的数据修改,就能保存id。

如果还有别的疑问,可以留言,我尽量的帮忙,毕竟自己也是菜鸟前端。
在搜索的其他问题,最高是对比下版本。不然报的错,会怀疑自我

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值