java fullcalendar,fullcalendar的简单实用

1.

Title

$('#ename1').change( function(){

var eid = $("#ename1 option:selected").val()

var events = {

url: "/appoint/selectTids",

type: 'post',

data: {

"eid":eid

}

}

$('#calendar').fullCalendar( 'removeEventSource', events)

$('#calendar').fullCalendar( 'addEventSource', events)

$('#calendar').fullCalendar( 'refetchEvents' )

}).change()

251b3fe59a05

效果图

2.

Title

#top {

background: #eee;

border-bottom: 1px solid #ddd;

padding: 0 10px;

line-height: 40px;

font-size: 12px;

}

#calendar {

margin: 40px auto;

padding: 0 10px;

}

.done:before {

content:"【 已完成 】";

background-color:yellow;

color:green;

text-align:center;

font-weight:bold;

width:100%;

}

.doing:before {

content:"【 未完成 】";

background-color:yellow;

color:red;

text-align:center;

font-weight:bold;

}

$(document).ready(function() {

var initialLangCode = 'en';

$('#calendar').fullCalendar({

header: {

left: 'prev,next today',

center: 'title',

right: 'month,agendaWeek,agendaDay'

},

weekends: true,

weekMode: 'liquid',

defaultView: 'month',

allDayText: '全天',

businessHours: true,

defaultEventMinutes: 120,

eventLimit: true,

dayClick : function(date,id) {

console.log('dayClick触发的时间为:', date.format());

var da=new Date(date);

var b=da.getHours()-8;

var date1=new Date(da.setHours(b));

var a=da.getMinutes()+30;

alert(date1);

var date2=new Date(date1.setMinutes(a));

alert(date2);

alert(id);

alert(data-date);

},

//设置是否可被单击或者拖动选择

selectable: true,

//点击或者拖动选择时,是否显示时间范围的提示信息,该属性只在agenda视图里可用

selectHelper: true,

//点击或者拖动选中之后,点击日历外的空白区域是否取消选中状态 true为取消 false为不取消,只有重新选择时才会取消

unselectAuto: true,

select: function( start, end ){

console.log('select触发的开始时间为:', start.format());

console.log('select触发的结束时间为:', end.format());

},

eventClick : function( event ){

console.log('eventClick中选中Event的id属性值为:', event.id);

console.log('eventClick中选中Event的title属性值为:', event.title);

console.log('eventClick中选中Event的start属性值为:', event.start.format('YYYY-MM-DD HH:mm'));

console.log('eventClick中选中Event的end属性值为:', event.end==null?'无':event.end.format('YYYY-MM-DD HH:mm'));

console.log('eventClick中选中Event的color属性值为:', event.color);

console.log('eventClick中选中Event的className属性值为:', event.className);

},

eventMouseover : function( event ) {

console.log('鼠标经过 ...');

console.log('eventMouseover被执行,选中Event的title属性值为:', event.title);

},

eventMouseout : function( event ) {

console.log('eventMouseout被执行,选中Event的title属性值为:', event.title);

console.log('鼠标离开 ...');

},

//Event是否可被拖动或者拖拽

editable: true,

//Event被拖动时的不透明度

dragOpacity: 0.5,

eventDrop : function( event, dayDelta, revertFunc ) {

//do something here...

console.log('eventDrop --- start ---');

console.log('eventDrop被执行,Event的title属性值为:', event.title);

if(dayDelta._days != 0){

console.log('eventDrop被执行,Event的start和end时间改变了:', dayDelta._days+'天!');

}else if(dayDelta._milliseconds != 0){

console.log('eventDrop被执行,Event的start和end时间改变了:', dayDelta._milliseconds/1000+'秒!');

}else{

console.log('eventDrop被执行,Event的start和end时间没有改变!');

}

console.log('eventDrop --- end ---');

},

eventResize : function( event, dayDelta, revertFunc ) {

console.log(' --- start --- eventResize');

console.log('eventResize被执行,Event的title属性值为:', event.title);

if(dayDelta._days != 0){

console.log('eventResize被执行,Event的start和end时间改变了:', dayDelta._days+'天!');

}else if(dayDelta._milliseconds != 0){

console.log('eventResize被执行,Event的start和end时间改变了:', dayDelta._milliseconds/1000+'秒!');

}else{

console.log('eventResize被执行,Event的start和end时间没有改变!');

}

console.log('--- end --- eventResize');

},

});

//初始化语言选择的下拉菜单值

$.each($.fullCalendar.langs, function(langCode) {

$('#lang-selector').append(

$('')

.attr('value', langCode)

.prop('selected', langCode == initialLangCode)

.text(langCode)

);

});

//当选择一种语言时触发

$('#lang-selector').on('change', function() {

if (this.value) {

$('#calendar').fullCalendar('option', 'lang', this.value);

}

});

events: [

{

id: 1,

title: '这是一个all-day数据',

allDay: true,

start: '2018-12-11'

},

{

id: 2,

title: '开始时间为12PM',

start: '2018-12-11 12:00'

},

{

id: 3,

title: '给一点颜色',

start: '2018-12-4',

color: 'red'

},

{

id: 4,

title: '使用className:done',

start: '2018-12-10 09:00',

end: '2018-12-11 18:00',

color: 'blue',

className: 'done'

},

{

id: 5,

title: '使用className:doing',

start: '2018-12-11 09:00',

end: '2018-12-12 18:00',

color: 'green',

className: 'doing'

},

{

id: 6,

title: '使用URL和字体颜色',

start: '2019-12-4',

color: 'pink',

url: 'http://foreknow.com',

className: 'doing',

textColor: 'black'

},

{

id: 7,

title: '使用backgroundColor和borderColor',

start: '2018-12-11 09:00',

end: '2018-12-12 18:00',

backgroundColor: 'gray',

borderColor: 'red',

className: 'done'

},

]

});

251b3fe59a05

效果图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
fullcalendar是一个功能强大的日历插件,可以用于在网页中显示和管理日程安排。为了在Vue项目中使用fullcalendar插件,你需要按照以下步骤进行操作: 1. 在项目中创建一个Vue文件,并在`<script>`标签中引入fullcalendar插件及其相关插件,例如`@fullcalendar/daygrid`、`@fullcalendar/timegrid`、`@fullcalendar/interaction`、`@fullcalendar/list`。可以使用npm或yarn从官方的npm库中安装这些插件。 2. 在Vue文件的`<template>`标签中,使用`<FullCalendar>`组件来显示日历。可以使用`ref`属性给FullCalendar组件命名,方便在后续的代码中引用。 3. 在Vue文件的`<script>`标签中,将FullCalendar组件注入到Vue实例的`components`选项中,以便在Vue文件中使用FullCalendar组件。 下面是一个示例代码,演示了如何在Vue项目中使用fullcalendar插件: ```javascript <template> <FullCalendar ref="fullCalendar"></FullCalendar> </template> <script> import FullCalendar from '@fullcalendar/vue' import dayGridPlugin from '@fullcalendar/daygrid' import timeGridPlugin from '@fullcalendar/timegrid' import interactionPlugin from '@fullcalendar/interaction' import listPlugin from '@fullcalendar/list' export default { components: { FullCalendar }, mounted() { // 在这里进行日历的初始化和配置 const calendarEl = this.$refs.fullCalendar.$el const calendar = new FullCalendar(calendarEl, { plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin, listPlugin], // 其他配置项... }) } } </script> ``` 请注意,你需要根据自己的项目情况进行相应的配置和调整,如设置插件的具体功能、样式等。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值