我冻结了我的应用程序。我想使用像函数这样的变量来创建自己的report.js文件,但无法对其进行初始化。我要复制模板中已经完成的其他内容,但是我不明白为什么我的代码无法正常工作。
这是我称之为头部的部分。
$(document).ready(function(){
"use strict";
App.init(); // Init layout and core plugins
Plugins.init(); // Init all plugins
FormComponents.init(); // Init all form-specific plugins
Reports.init();
$('#StartDate').pickadate({
formatSubmit: 'yyyy/mm/dd',
hiddenName: true
});
});
当我运行站点时,控制台显示TypeError:Reports.init不是函数
现在,我将共享report.js文件:
var Reports = function () {
"use strict";
var form = $('form').attr('id');
alert(form);
/* * * * * * * * * * * * * * *
* Employee Clock-In Clock-Out
* * * * * * * * * * * * * * */
var EmployeeClocks = function(form) {
// will do something
}
return {
// main function to initiate reports
init: function () {
// EmployeeClocks();
},
};
}
添加()
。您Reports
现在是一个函数,而不是一个类。但是此函数返回您想要的东西。
var Reports = function () { ... }()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句