- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为一个 Ionic 3 项目编写代码,我在该项目中使用 FullCalendar 插件来显示日历 UI。当我尝试更改日历上一天的背景时,页面模块中的这段代码出现问题。我使用了 FullCalendar 的 dayRender 函数。
$('#calendar').fullCalendar({
dayRender: function (date, cell) {
var today = new Date('2017-09-11T00:40Z')
if (date.getDate() == today.getDate()) {
this.cell.css("background-color", "red");
}
},
});
我在输出中有这个运行时错误:
date.getDate() is not a function. (In 'date.getDate()', 'date.getDate()' is undefined) FullCalendar in Ionic 3
所以我不明白为什么,因为日期是一个已经在 FullCalendar 库中定义的日期对象。
任何解决方案?
ps:抱歉我的英语不好。
最佳答案
dayRender
回调的文档位于 https://fullcalendar.io/docs/v3/dayRender说
date
is the Moment for the given day.
所以 date
在你的代码中是一个 momentJS 对象,而不是 Date 对象。这就是为什么 getDate 方法不存在的原因。您最好也将 today
创建为 momentJS 对象,然后您可以直接比较它们:
$('#calendar').fullCalendar({
dayRender: function (date, cell) {
var today = moment('2017-09-11T00:00Z');
if (date.isSame(today, "day")) {
cell.css("background-color", "red");
}
},
//...
});
有关我编写的代码的更多详细信息,请参阅 http://momentjs.com/docs/#/parsing/string/有关 moment 构造函数可以解析的日期的详细信息,以及 http://momentjs.com/docs/#/query/is-same/有关日期比较方法的详细信息。
您可以在此处查看上面的工作示例:http://jsfiddle.net/sbxpv25p/22/
关于javascript - date.getDate() 不是函数。 (在 'date.getDate()' 中, 'date.getDate()' 未定义)Ionic 3 中的 FullCalendar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46279355/
有没有办法在 FullCalendar 中动态更改事件模板? 更新。 我想要的是指定新的事件 html(例如在 eventRender 回调中)并使 FullCalendar 将其用于我的事件渲染。像
我正在使用 FullCalendar 组件,我需要为周末、周五和周六着色。 我已经按照这里的建议使用了以下内容: Can I set a different color for the weekend
我正在实现 fullcalendar 并在时区问题上苦苦挣扎。 这是代码: $('#calendar').fullCalendar({ //re-initialize the calendar
我希望 fullCalendar 在不重新加载页面的情况下重绘自身(所有结构和事件)。 场景: 我正在使用支持 Resource View 的 fullCalendar 补丁。 .对于一些用户操作,我
我想在同一页面上添加多个 FullCalendars(可选)以安排不同类型的事件并将信息保存在数据库中,但查看演示/示例代码,我似乎每页只能添加一个日历,因为它由 呈现。 .您能否让我知道是否有办法
我已将 FullCalendar 设置为接受 drop,确实如此。但是我用 revert:'invalid' 构造的可拖动对象似乎无法将 FullCalendar 上的日期识别为可放置的,并恢复回来。
我公司最近购买了 Full-Calendar Scheduler 插件。有没有正确的方法在代码中隐藏许可证 key ?对此有哪些好的做法? 最佳答案 你是对的,没有办法完全隐藏 schedulerLi
在 FullCalendar如何使资源可点击? 我已经检查了 API,但我看不到任何相关内容,我是否遗漏了什么? 我在找 resource-click -事件就像我们对事件一样? 最佳答案 在 res
我有额外的数据(在我的例子中是一个数字),它是通过一个 javascript 函数获得的——我想在每天的单元格中显示它。 例如 - 如果天数在右上角,我希望它显示在左上角 - 每天自动显示。 我看到有
我在单个页面上创建多个 fullcalendar,我想编写一个事件渲染回调,以便它可以从调用它的 fullcalendar 实例中读取选项,例如 minTime 和 maxTime,不知道如何做这个。
看起来默认值为 20 像素,但我希望将其提高,因此长度为 1 个时隙的事件将能够显示事件标题和正文。当前,当事件长度为 1 个时隙时,仅显示事件标题。 最佳答案 任何仍在寻找新版本答案的人。 在新版本
我正在尝试实现 this solution在 Fullcalendar 中“变灰”过去的事件,但我没有任何运气。不过,我不太精通 Javascript,所以我认为我犯了一些愚蠢的错误。 我已经将建议的
我使用 jQuery fullCalendar (http://arshaw.com/fullcalendar/docs/selection/unselectAuto/) 我使用这个日历的可选版本 (
这看起来非常简单,但我花了半天时间把头撞在墙上,试图弄清楚为什么我的全日历事件只显示在 77 像素,而单元格(月 View )的宽度似乎是 90 像素或更高。我曾尝试修改 fc-event css 规
我正在尝试在全日历中将时间格式更改为 24 小时制。 我试图找到它 here但我无法弄清楚。 这里的代码片段: jQuery('#calendar').fullCalendar({ heade
在月 View 中 fullcalendar 有一个很好的功能,可以在非全天事件的顶行显示开始时间。如果您不想在事件标题中提供更多详细信息,这可能很有用。 我想在月 View 中显示几个详细信息,例如
如何在 fullcalendar 中显示事件的描述? 我有具有标题和描述的事件。 那么如何显示描述呢? 最佳答案 当您添加标题和描述时,它将连接起来。 使用以下代码,您可以连接标题: eventRen
我正在尝试使用 FullCalendar 在网页上呈现 Google 日历中的事件。我想要开始日期/时间、描述和地点。 future 事件在一个 div 中,过去事件在另一个 div 中。 现在,我的
我正在尝试突出显示 FullCalender.io 中的选定日期(与当前日期类似)。 已关注 FullCalendar - Highlight a particular day in week vie
我是 FullCalendar 新手。在我的项目中,我需要显示带有时间范围的日历以及每天为每个培训中心分配的参与者。更准确地说,一天可以有很多个培训时段,由培训中心进行。因此,我想展示哪个培训中心分配
我是一名优秀的程序员,十分优秀!