gpt4 book ai didi

javascript - jQuery fullCalendar 在标题上显示未定义

转载 作者:可可西里 更新时间:2023-11-01 02:08:50 33 4
gpt4 key购买 nike

我在 ReactJs 组件上使用 jQuery fullcalendar。

我有一个 <div id="calendar"></div>在渲染方法上

在 componentDidUpdate 上,我使用以下代码更新了日历:

$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},

events: _this.state.events,
defaultView:'month',
displayEventTime: false,
editable: false,
droppable: false,
durationEditable: false
});

它在标题上显示“未定义”字符。我哪里做错了?以及如何调试未定义字符串的来源?

jquery full calendar

目前,我做了一个黑客解决方案,通过添加以下内容从标题中删除所有未定义的字符串:

viewRender: function(view, element) {
//note: this is a hack, i don't know why the view title keep showing "undefined" text in it.
//probably bugs in jquery fullcalendar
$('.fc-center')[0].children[0].innerText = view.title.replace(new RegExp("undefined", 'g'), ""); ;

},

有没有更好的解决方案?

我正在使用 jquery FullCalendar v2.9.1

使用以下事件示例数据:

[{"start":"2017-03-24T00:00:00.000Z","end":"2017-03-26T00:00:00.000Z","title":"Open house","description":"Bali 1 open house"}]

注意:我最终放弃了 jquery 完整日历以支持 react-big-calendar。

最佳答案

我在升级 fullCalendar 后遇到了同样的问题,我花了一些时间才弄清楚,因为近一年来一切都运行良好,我过去升级过 fullCalendar 没有任何问题,出于某种原因我不得不包括 moment.js 在我使用 fullCalendar 的页面中,看到我运行了一个 MVC 站点,之前母版页 (_layout.cshtml) 引用了 moment.js ,现在不确定为什么它不再起作用,就像测试一样,我在实际页面中添加了对 moment 的引用,我使用 fullCalendar 并且 undefindundefined 消失了,我遇到的另一个问题也是如此。

在我的例子中,修复是:

@Scripts.Render("~/bundles/dates") 

在你的情况下,它可能只是:

<script src='//cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js'></script>

关于javascript - jQuery fullCalendar 在标题上显示未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43227050/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com