[英]Full Calendar if start is same with end dates
I have full calendar and when getting the data for event I get error in this line 我有完整的日历,当获取事件的数据时,我在此行中收到错误
end: event.end.format() || event.start.format(),
saying 话
Uncaught TypeError: Cannot read property 'format' of undefined 未捕获的TypeError:无法读取未定义的属性“格式”
a work around is 解决方法是
eventClick: function(event) {
var start = event.start;
var end = event.end || start;
}
but it didnt work for me 但它对我没有用
What is the best way to handle end date in full calendar 在完整日历中处理结束日期的最佳方法是什么
eventData = {
id: id,
sysid: sysid,
title: title,
start: event.start.format(),
end: event.end.format() || event.start.format(),
description: description,
otherinformation: otherinformation,
page: page,
action: action
};
Problem with your implementation is it checks for truthy ofthe formatted value, it doesn't evaluate whether event.end
is truthy . 您的实现问题是它检查格式化值的真实性 ,它不评估event.end
是否真实 。 So when event.end
evaluated to falsey
the error is thrown. 因此,当event.end
评估为falsey
,抛出错误。
You should check for event.end
to be truthy , thus use 你应该检查event.end
是否真实 ,因此使用
end: (event.end || event.start).format()
Or, As suggest by API Docs 或者,正如API Docs所建议的那样
var start = event.start;
var end = event.end || start;
eventData = {
end: end.format(),
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.