vue-full-calendar基本使用

vue-full-calendar基本使用

安装

npm install vue-full-calendar
npm install moment

全局引入
可以将fullcalendar里面fullcalendar.css放到assets中,方便对日历样式进行自定义的修改

import FullCalendar from 'vue-full-calendar'
import './assets/fullcalendar.css'
Vue.use(FullCalendar)

安装jqery

npm i jquery --save-d

全局引入jqery

//在main.js中引入
import jquery from 'jquery'
Vue.prototype.$ = jquery

设置周六周日背景色
在fullcalendar.css添加

/*星期六背景色和字体颜色wheat */
.fc-unthemed td.fc-sat{
  /*background: #F5DEB3;*/
  background-color:#8fdf82;
}
/*星期天背景色和字体颜色burlywood */
.fc-unthemed td.fc-sun{
  /*background: #DEB887;*/
  background-color:#8fdf82 ;
}

页面代码

<template>
  <div class="hello">
    <full-calendar ref="calendar" :events="events" :config="config">
    </full-calendar>
  </div>
</template>
<script>
var demoEvents = [
  {
    title: "Sunny Out of Office",
    start: "2021-04-05",
    end: "2021-04-05",
    backgroundColor: "green",
    // borderColor:"none",
    // color:"black", // 背景色和边框色
    // textColor:"white",
  },
  {
    title: "Sunny Out of Office",
    start: "2021-04-06",
    end: "2021-04-06",
  },
];
export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  data() {
    return {
      events: demoEvents,
      config: {
        locale: "zh-cn",
        defaultView: "month",
        firstDay:1,
        header: {
          left: "",
          center: "title",
          right: "",
        },
        editable: false, // 禁止拖动
        aspectRatio: 2,
        eventLimit: 3, // 限制一天中显示的事件数,默认false
        eventClick: this.eventClick,
      },
    };
  },
  created() {
    this.$nextTick(() => {
      // 在 header title 左边 插入 自定义按钮
      this.$(".fc-center").prepend(
        this.$(
          '<button type="button" class="fc-button fc-state-default fc-corner-left fc-corner-right"> < </button>'
        ).on("click", () => {
          this.$refs.calendar.fireMethod("prev");
        })
      );
      // 在 header title 右边 插入 自定义按钮
      this.$(".fc-center").append(
        this.$(
          '<button type="button" class="fc-button fc-state-default fc-corner-left fc-corner-right"> > </button>'
        ).on("click", () => {
          this.$refs.calendar.fireMethod("next");
        })
      );
    });
  },
  methods: {
    eventClick: function (event, jsEvent, view) {
      console.log("??");
    },
  },
};
</script>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值