IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> JavaScript知识库 -> full-canlender -> 正文阅读

[JavaScript知识库]full-canlender

full-canlender

转载:
https://blog.csdn.net/qq_38543537/article/details/112003394

官方文档:

组件
FullCalendar 与Vue JavaScript 框架无缝集成。它提供了一个与 FullCalendar 的标准 API 的功能完全匹配的组件。

这个包是在 MIT 许可下发布的,与 FullCalendar 的标准版本使用的许可相同。有用的链接:

浏览 Github 存储库(请为它加注星标!)
错误报告说明
示例项目:
Vue 2 示例(使用Webpack和css-loader) -可运行
Vue 3 示例(使用TypeScript和Vite) -可运行
本指南不会深入探讨初始化 Vue 项目。请查阅上述示例/可运行项目。

第一步是安装Vue适配。如果使用Vue 2:

npm install --save @fullcalendar/vue @fullcalendar/core
如果使用Vue 3:

npm install --save @fullcalendar/vue3 @fullcalendar/core
然后安装任何其他 FullCalendar 插件,如 @fullcalendar/daygrid

然后,您可以开始编写利用该组件的父组件:

<script>
import '@fullcalendar/core/vdom' // solves problem with Vite
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>
建议@fullcalendar/core/vdom在任何其他导入之前导入。这对于Vite的 HMR 工作尤其重要。有关更多信息,请参阅票证 #152。

CSS
只要您的构建系统能够处理.css文件导入,所有 FullCalendar 的 CSS 都会自动加载。有关配置构建系统的更多信息,请参阅使用 ES6 构建系统初始化。

道具和发射事件
Vue 有“道具”(viav-bind或:)与“事件”(viav-on或@)的概念。对于 FullCalendar 连接器,道具和事件之间没有区别。一切都options作为键值对传递到主对象中。这是一个演示传入events数组和dateClick处理程序的示例:

<script>
import '@fullcalendar/core/vdom' // solves problem with Vite
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',
        dateClick: this.handleDateClick,
        events: [
          { title: 'event 1', date: '2019-04-01' },
          { title: 'event 2', date: '2019-04-02' }
        ]
      }
    }
  },
  methods: {
    handleDateClick: function(arg) {
      alert('date click! ' + arg.dateStr)
    }
  }
}
</script>
<template>
  <FullCalendar :options="calendarOptions" />
</template>

修改选项
您可以在初始化后通过在选项对象中重新分配日历选项来修改日历选项。这是更改weekends选项的示例:

<script>
import '@fullcalendar/core/vdom' // solves problem with Vite
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',
        weekends: false // initial value
      }
    }
  },
  methods: {
    toggleWeekends: function() {
      this.calendarOptions.weekends = !this.calendarOptions.weekends // toggle the boolean!
    }
  }
}
</script>
<template>
  <button @click="toggleWeekends">toggle weekends</button>
  <FullCalendar :options="calendarOptions" />
</template>

FullCalendar 实用程序
通常可以通过 访问的所有 FullCalendar 实用程序功能@fullcalendar/core也可以通过 访问@fullcalendar/vue。该formatDate工具例如。这可以防止您需要向项目添加另一个依赖项。

import { formatDate } from '@fullcalendar/vue';

let str = formatDate(new Date(), {
  month: 'long',
  year: 'numeric',
  day: 'numeric'
});

console.log(str);

日历 API
希望您不需要经常这样做,但有时访问Calendar原始数据和方法的底层对象很有用。

这对于控制当前日期特别有用。该initialDate道具将设置初始日历的日期,但之后改变它,你需要依靠日期导航方法。

要执行这样的操作,您需要获得组件的 ref(“reference”的缩写)。在模板中:

获得 ref 后,您可以Calendar通过以下getApi方法获取底层对象:
let calendarApi = this.$refs.fullCalendar.getApi()
calendarApi.next()

标记中的烤肉串案例
有些人在编写标记时更喜欢在 kebab-case 中编写组件名称。这将正常工作:

<full-calendar :options="calendarOptions" />

但是,其中的属性calendarOptions必须具有相同的名称。

全日历高级版
你如何在Vue 中使用FullCalendar Premium 的插件?它们与任何其他插件没有什么不同。只需按照与dayGridPlugin上述示例相同的说明进行操作即可。另外,请确保包含您的schedulerLicenseKey:

<script>
import '@fullcalendar/core/vdom' // solves problem with Vite
import FullCalendar from '@fullcalendar/vue'
import resourceTimelinePlugin from '@fullcalendar/resource-timeline'

export default {
  components: {
    FullCalendar
  },
  data() {
    return {
      calendarOptions: {
        plugins: [ resourceTimelinePlugin ],
        schedulerLicenseKey: 'XXX'
      }
    }
  }
}
</script>
<template>
  <FullCalendar :options="calendarOptions" />
</template>
  JavaScript知识库 最新文章
ES6的相关知识点
react 函数式组件 & react其他一些总结
Vue基础超详细
前端JS也可以连点成线(Vue中运用 AntVG6)
Vue事件处理的基本使用
Vue后台项目的记录 (一)
前后端分离vue跨域,devServer配置proxy代理
TypeScript
初识vuex
vue项目安装包指令收集
上一篇文章      下一篇文章      查看所有文章
加:2021-07-13 17:22:27  更:2021-07-13 17:24:43 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/4 23:26:11-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码