【发布时间】:2016-05-07 20:09:34
【问题描述】:
我是 js 的新手,我想覆盖/覆盖另一个脚本 (my-fullcalendar.js) 中的一些 fullcalendar 函数,以便为自己做一些更改。例如函数名称是:
formatRange 和 oldMomentFormat。
formatRange 可以通过 this.$.fullCalendar.formatRange 访问,但 oldMomentFormat 不能通过这种链访问。但即使我在 my-fullcalendar.js 中做这样的事情:
;(function () {
function MyformatRange(date1, date2, formatStr, separator, isRTL) {
console.log( "MyformatRange");
//other parts is exactly the same
// ...
}
this.$.fullCalendar.formatRange=MyformatRange;
console.log(this);
})();
什么都没有发生,因为没有生成日志,甚至逐行跟踪也没有从这里通过。但是当在控制台日志中观察“this”时,MyformatRange 被原始 formatRange 替换。 另一个问题是如何覆盖/覆盖不在窗口层次结构中访问的 oldMomentFormat 函数(或者我找不到它)??
【问题讨论】:
-
该代码应该可以工作。确保以正确的顺序加载所有内容。
-
我如何确定所有内容都以正确的顺序加载?我的 js 脚本按以下顺序排列: 。那么oldMomentFormat呢??
标签: javascript fullcalendar overriding overwrite