我正在使用 Electron 创建一个小桌面应用程序并使用module.exports
. 在“服务器”端,这工作正常。但是,当我在前端使用 module.exports 时,根据 Electron 文档,我收到此错误。
Uncaught TypeError: this.showProgressbar is not a function"
var ViewController = {
getPageCount: function (res) {
this.total = res;
this.showProgressbar(res);
},
showProgressBar: function (num) {
$('.progress-container').addClass('show');
$('.progress-bar').style('width', '0%');
}
};
module.exports = ViewController;
在客户端,这就是我访问此文件的方式。
var view = require(__dirname + '/client/ViewController.js');
ipc.on('page_count', view.getPageCount);
在这种情况下,我应该如何访问内部方法?