首页 > 其他分享 >fullcalendar-vue3插件实现时间资源图

fullcalendar-vue3插件实现时间资源图

时间:2024-05-20 14:32:02浏览次数:8  
标签:插件 title fullcalendar 05 00 2024 vue3 id

用的vue3+最新版本:官网链接:https://fullcalendar.io/demos

效果如图:x轴为人员,y轴为当日的时间段:

 

 1. 安装 引入


npm install --save @fullcalendar/core @fullcalendar/resource @fullcalendar/resource-timegrid

 package.json

 2. 附上代码

<script>
import { defineComponent } from "vue";
import FullCalendar from "@fullcalendar/vue3";
import resourceTimeGridPlugin from "@fullcalendar/resource-timegrid";

export default defineComponent({
  components: {
    FullCalendar,
  },
  data() {
    return {
      currentEvents: [
        {
          resourceId: "a",
          title: "事件标题1",
          start: "2024-05-20T12:00:00+00:00",
          end: "2024-05-21T06:00:00+00:00",
        },
        {
          resourceId: "b",
          title: "事件标题2",
          start: "2024-05-20T12:00:00+00:00",
          end: "2024-05-21T06:00:00+00:00",
        },
      ],

      calendarOptions: {
        plugins: [resourceTimeGridPlugin],
        initialView: "resourceTimeGridDay",
        locale: "zh",
        resources: [
          { id: "a", title: "张三" },
          { id: "b", title: "李四" },
          { id: "c", title: "张三" },
          { id: "d", title: "张三" },
          { id: "e", title: "张三" },
          { id: "f", title: "李四" },
          { id: "g", title: "张三" },
          { id: "h", title: "张三" },
          { id: "a1", title: "张三" },
          { id: "b1", title: "李四" },
          { id: "c1", title: "张三" },
        ],
        events: [
          {
            resourceId: "a", // 事件的唯一标识符
            title: "标题1", // 事件的标题
            start: "2024-05-20T10:00:00", // 事件的开始时间(ISO 8601 格式)
            end: "2024-05-20T11:30:00", // 事件的结束时间(ISO 8601 格式)
          },
          {
            resourceId: "c", // 事件的唯一标识符
            title: "事件标题3", // 事件的标题
            start: "2024-05-20T12:00:00", // 事件的开始时间(ISO 8601 格式)
            end: "2024-05-20T13:00:00", // 事件的结束时间(ISO 8601 格式)
          },
          {
            resourceId: "b",
            title: "事件标题2",
            start: "2024-05-20T12:00:00", // 事件的开始时间(ISO 8601 格式)
            end: "2024-05-20T14:30:00", // 事件的结束时间(ISO 8601 格式)
          },
        ],
        // 时间轴间距
        slotMinTime: "09:00:00", // 最小时间
        slotMaxTime: "21:00:00", // 最大时间
        // 原来的
        //  slotDuration: '01:00:00',
        //  slotDuration: '00:30:00',
        slotLabelFormat: {
          hour: "numeric",
          minute: "2-digit",
          hour12: false,
        },
        eventTimeFormat: {
          hour: "numeric",
          minute: "2-digit",
          hour12: false,
        },
        datesSet: this.handleEvents,
      },
    };
  },
  methods: {
    handleEvents(events) {
      console.log(events);
    },
  },
});
</script>

<template>
  <div class="demo-app">
    <div class="demo-app-main">
      <FullCalendar class="demo-app-calendar" :options="calendarOptions">
      </FullCalendar>
    </div>
  </div>
</template>

<style lang="css">
h2 {
  margin: 0;
  font-size: 16px;
}

ul {
  margin: 0;
  padding: 0 0 0 1.5em;
}

li {
  margin: 1.5em 0;
  padding: 0;
}

b {
  /* used for event dates/times */
  margin-right: 3px;
}

.demo-app {
  display: flex;
  min-height: 100%;
  font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  font-size: 14px;
}

.demo-app-sidebar {
  width: 300px;
  line-height: 1.5;
  background: #eaf9ff;
  border-right: 1px solid #d3e2e8;
}

.demo-app-sidebar-section {
  padding: 2em;
}

.demo-app-main {
  flex-grow: 1;
  padding: 3em;
}

.fc {
  /* the calendar root */
  max-width: 1100px;
  margin: 0 auto;
}
</style>
View Code

标签:插件,title,fullcalendar,05,00,2024,vue3,id
From: https://www.cnblogs.com/shyhuahua/p/18201833

相关文章

  • 基于 Spring Boot3、Vue3!这套小说系统开源了...
    大家好,我是Java陈序员。今天,给大家介绍一个基于SpringBoot3、Vue3前后端分离的小说项目,集成了主流的技术栈,可供学习使用!关注微信公众号:【Java陈序员】,获取开源项目分享、AI副业分享、超200本经典计算机电子书籍等。项目介绍novel——一套基于SpringBoot3+Vue3开发......
  • Vue3使用vue3-puzzle-vcode进行滑动验证
    npm包地址:https://www.npmjs.com/package/vue3-puzzle-vcodenpm安装npminstallvue3-puzzle-vcode--save最简单例子:<template><Vcode:show="isShow"@success="onSuccess"@close="onClose"/><button@click="on......
  • Vue3+Yup进行数据验证
    Vue3+Yup进行数据验证npm安装:npmiyup使用import*asYupfrom"yup";//配置constlogin=Yup.object().shape({//username为string格式,必填(错误提示为:请输入用户名)username:Yup.string().required('请输入用户名').label("username"),password:Yup.s......
  • Vue3+nanoid编写字符串ID生成器
    Vue3+nanoid编写字符串ID生成器中文介绍:https://github.com/ai/nanoid/blob/HEAD/README.zh-CN.md一个小巧、安全、URL友好、唯一的JavaScript字符串ID生成器。“一个惊人的无意义的完美主义水平,这简直让人无法不敬佩。”小巧. 116字节(经过压缩和Brotli处理)。没有依......
  • Vue3+sweetalert2消息提示类
    为了快速编写信息提示代码,封装如下core\helper中增加swalMessage.ts,代码如下代码importSwalfrom"sweetalert2"declareinterfaceSwalMessage{success(title:string,msg:string);error(title:string,msg:string);info(title:string,msg:string);ques......
  • Vue3使用vue-cropper截图上传
    !!!!!!!已使用另一个截图上传工具,稍后更新博客!!!!!!使用vue-cropper进行截图上传先安装npmivue-cropper编写组件在components中添加imageCropper.vue代码如下<template><div><div><imgv-if="value"class="mb-2"style=&......
  • Vue3使用SM国产加密库
    npm安装npminstall--savesm-crypto//使用import{sm2,sm3,sm4}from'sm-crypto'//-----------sm2--------------------//获取密钥对letkeypair=sm2.generateKeyPairHex()publicKey=keypair.publicKey//公钥privateKey=keypair.privateKey//私钥//......
  • Vue3+axios+.Net使用分片上传
    Vue3+axios+.Net使用分片上传前端代码在ApiService.cs中增加方法//上传文件publicstaticasyncuploadFile(file){constchunkSize=1024*1024;//1MB每1mb分片consttotalChunks=Math.ceil(file.size/chunkSize);letkey='';lettag=true;leturl=......
  • 自研WPF插件系统(沙箱运行及热插拔)
    前言插件化的需求主要源于对软件架构灵活性的追求,特别是在开发大型、复杂或需要不断更新的软件系统时,插件化可以提高软件系统的可扩展性、可定制性、隔离性、安全性、可维护性、模块化、易于升级和更新以及支持第三方开发等方面的能力,从而满足不断变化的业务需求和技术挑战。一......
  • 【Mybatis/Mybaits-Plus】【插件】插件执行时机
    1 前言我之前看过插件的执行过程:【Mybatis】【插件】Mybatis源码解析-插件机制,主要是通过一个 Executor的创建以及执行过程串了一下插件,我们这里简单回忆下:(1)Mybatis把所有的插件都放进了 InterceptorChain类里的 interceptors集合里(2)插件的两个时机:入场时机:插件是在......