Vue进阶(幺柒贰):应用 @fullcalendar vue 实现日程日历_vue实现一周的日程并拥有点击触发

React

  • 介绍一下react

  • React单项数据流

  • react生命周期函数和react组件的生命周期

  • react和Vue的原理,区别,亮点,作用

  • reactJs的组件交流

  • 有了解过react的虚拟DOM吗,虚拟DOM是怎么对比的呢

  • 项目里用到了react,为什么要选择react,react有哪些好处

  • 怎么获取真正的dom

  • 选择react的原因

  • react的生命周期函数

  • setState之后的流程

  • react高阶组件知道吗?

  • React的jsx,函数式编程

  • react的组件是通过什么去判断是否刷新的

  • 如何配置React-Router

  • 路由的动态加载模块

  • Redux中间件是什么东西,接受几个参数

  • redux请求中间件如何处理并发

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

4.scriptFullCalendar属性方法注解;

二、安装 Fullcalendar

Vue框架下,fullcalendar被封装成了几种不同的版本,

  • @ fullcalendar/vue
  • vue-fullcalendar

需要注意的是,以上两种用法不一样,不要搞混淆了!

本文重点关注第一种 @ fullcalendar/vue 的用法。经实践,第二种实现效果不友好。

首先下载安装相关依赖包。

npm install --save @fullcalendar/vue @fullcalendar/core @fullcalendar/daygrid @fullcalendar/interaction @fullcalendar/timegrid

三、简易 DEMO

<template>
	<FullCalendar :options="calendarOptions" class="eventDeal-wrap"/>
</template>

<script>
import FullCalendar from '@fullcalendar/vue'
import dayGridPlugin from '@fullcalendar/daygrid'
import interactionPlugin from '@fullcalendar/interaction'
import timeGridPlugin from '@fullcalendar/timegrid'
import '@fullcalendar/core/main.css'
import '@fullcalendar/daygrid/main.css'

export default {
  name: 'DEMO',
  components: {
    FullCalendar
  },
  data () {
    return {
		calendarOptions: {
          // 引入的插件
          plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin],
          // 日历头部按钮位置
          headerToolbar: {
            left: 'prev,next today',
            center: 'title',
            right: 'dayGridMonth, timeGridWeek, timeGridDay'
          },
          // 日历头部按钮中文转换
          buttonText: {
            today: '今天',
            month: '月',
            week: '周',
            day: '天'
          },
          initialView: 'dayGridMonth', // 指定默认显示视图
          locale: 'zh-ch', // 切换语言,当前为中文
          firstDay: '1', // 设置一周中显示的第一天是周几,周日是0,周一是1,以此类推
          weekNumberCalculation: 'ISO', // 与firstDay配套使用
          eventCOlor: '#3d8eec', // 全部日历日程背景色
          timeGridEventMinHeight: '20', // 设置事件的最小高度
          aspectRatio: '1.5', // 设置日历单元格宽高比
          displayEventTime: false, // 是否显示事件时间
          allDaySlot: false, // 周、日视图时,all-day不显示
          eventLimit: true, // 设置月日程,与all-day slot 的最大显示数量,超过的通过弹窗展示
          eventTimeFormat: {
            hour: 'numeric',
            minute: '2-digit',
            hour12: false
          },
          slotLabelFormat: {
            hour: '2-digit',
            minute: '2-digit',
            meridiem: false,
            hour12: false // 设置时间为24小时制
          },
          events: [], // 日程数组
          // 事件
          editable: true, // 是否可以进行(拖动、缩放)修改
          eventStartEditable: true, // Event日程开始时间可以改变,默认为true,若为false,则表示开始结束时间范围不能拉伸,只能拖拽
          eventDurationEditable: true, // Event日程的开始结束时间距离是否可以改变,默认为true,若为false,则表示开始结束时间范围不能拉伸,只能拖拽
          selectable: true, // 是否可以选中日历格
          selectMirror: true,
          selectMinDistance: 0, // 选中日历格的最小距离
          weekends: true,
          navLinks: true, // 天链接
          selectHelper: false,
          selectEventOverlap: false, // 相同时间段的多个日程视觉上是否允许重叠,默认为true,允许
          dayMaxEvents: true,
          dateClick: this.handleDateClick, // 日期点击
          eventsSet: this.handleEvents, // 事件点击
          eventClick: this.handleEventClick, // 日程点击信息展示
          eventDrop: this.handleEventDrop, // 日程拖动事件
          eventResize: this.eventResize // 日程缩放事件
        }
    }
  },
  mounted () {

  },
  created () {

  },
  methods: {
    // 日程保存
      saveEvent (val) {
        let eventsArr = this.calendarOptions.events
        try {
          if (eventsArr.length === 0) {
            eventsArr.push(val)
          } else {
            eventsArr.forEach((item, index, eventsArr) => {
              // 若为修改日程
              if (item.eventID === val.eventID) {
                throw new Error(index)
              }
            })
            // 若为新增日程
            eventsArr.push(val)
          }
        } catch (e) {
          // 若为修改日程
          eventsArr.splice(e.message, 1, val)
        }
      },
      // 日程删除
      deleteEvent (val) {
        let eventsArr = this.calendarOptions.events
        try {
          eventsArr.forEach((item, index, eventsArr) => {
            if (item.eventID === val) {
              throw new Error(index)
            }
          })
        } catch (e) {
          // 删除指定日程
          eventsArr.splice(parseInt(e.message), 1)
        }
      },
      // 日程事件点击
      handleEvents (info) {
        console.log('handleEvents.info:', info)
        // this.currentEvents = events
      },
      handleWeekendsToggle () {
        console.log('handleWeekendsToggle')
        this.calendarOptions.weekends = !this.calendarOptions.weekends
      },
      // 日期点击
      handleDateClick (selectInfo) {
        if (confirm('您是否要在【' + selectInfo.dateStr + '】添加一个新的事件?')) {
          // 父组件直接调用子组件方法
          this.$refs['eventDialogue'].openDialog('add')
          // 父组件直接修改子组件变量
          // this.$refs['eventDialogue'].dialogVisible = true
        }
      },
      // 日程点击信息展示
      handleEventClick (info) {
        console.log('handleEventClick.info:', info)
        info.el.style.borderColor = 'red'
        this.$refs['eventDialogue'].openDialog('view', info)
      },
      // 日程事件触发
      eventClick (info) {


### React

*   介绍一下react

*   React单项数据流

*   react生命周期函数和react组件的生命周期

*   react和Vue的原理,区别,亮点,作用

*   reactJs的组件交流

*   有了解过react的虚拟DOM吗,虚拟DOM是怎么对比的呢

*   项目里用到了react,为什么要选择react,react有哪些好处

*   怎么获取真正的dom

*   选择react的原因

*   react的生命周期函数

*   setState之后的流程

*   react高阶组件知道吗?

*   React的jsx,函数式编程

*   react的组件是通过什么去判断是否刷新的

*   如何配置React-Router

*   路由的动态加载模块

*   Redux中间件是什么东西,接受几个参数

*   redux请求中间件如何处理并发

**[开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】](https://bbs.csdn.net/forums/4304bb5a486d4c3ab8389e65ecb71ac0)**

![](https://i-blog.csdnimg.cn/blog_migrate/07ceff5f577afdbcf69e14fc7b55a0e2.png)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值