在select上添加新事件时,FullCalendar似乎正在更改我的事件的开始和结束时间。这仅在月视图中发生,而不在agendaWeek视图中发生。
mounted () {
let vm = this
$(this.$refs.calendar).fullCalendar({
defaultView: 'month',
header: {
left: 'title',
center: '',
right: 'today agendaWeek,month prev,next'
},
allDaySlot: false,
allDayDefault: false,
firstDay: 1,
select: function (start, end, jsEvent, view, resourceObj) {
vm.addEvent(start, end, view)
}
})
},
methods: {
addEvent: function (start, end) {
// Here this.hour and this.minute are variables which in my example would be 6 and 0
from = moment(start).set({'hour': this.hour, 'minute': this.minute})
to = moment(end).set({'hour': this.hour, 'minute': this.minute})
this.renderEvent(from, to)
},
renderEvent: function (start, end) {
// Make temporary id
let tmpId = `tmp-${this.getLocalEvtId()}`
console.log(start.format('YYYY-MM-DD HH:mm'))
// Add new event
$(this.$refs.calendar).fullCalendar('renderEvent', {
id: tmpId,
title: 'NA',
start: start,
end: end,
color: '#bd362f',
editable: false
}, false)
// Find newly created event
let event = $(this.$refs.calendar).fullCalendar('clientEvents', tmpId)[0]
console.log(event.start.format('YYYY-MM-DD HH:mm'))
}
}
使用此代码添加事件时,第一个控制台。日志记录2018-04-10 06:00(或我设置为开始的任何时间),但第二个2018-04-10 00:00。从agendaWeek视图添加事件时,两个日志都记录在2018-04-10 06:00。有人经历过类似的问题吗?
编辑:
JSFIDLE公司
jsfiddle.net/sbxpv25p/494