我有完整的日历,当获取事件的数据时,我在此行中收到错误
end: event.end.format() || event.start.format(),话
未捕获的TypeError:无法读取未定义的属性“格式”
根据这个
解决方法是
eventClick: function(event) { var start = event.start; var end = event.end || start; }但它对我没有用
在完整日历中处理结束日期的最佳方法是什么
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 };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
According to this
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 };最满意答案
您的实现问题是它检查格式化值的真实性 ,它不评估event.end是否真实 。 所以当event.end评估为falsey ,抛出错误。
你应该检查event.end是否真实 ,因此使用
end: (event.end || event.start).format()或者,正如API Docs所建议的那样
var start = event.start; var end = event.end || start; eventData = { end: end.format(), };Problem with your implementation is it checks for truthy ofthe formatted value, it doesn't evaluate whether event.end is truthy. So when event.end evaluated to falsey the error is thrown.
You should check for event.end to be truthy, thus use
end: (event.end || event.start).format()Or, As suggest by API Docs
var start = event.start; var end = event.end || start; eventData = { end: end.format(), };
更多推荐
发布评论