私は Electron を使用して小さなデスクトップ アプリを作成し、module.exports. 「サーバー」側では、これは正常に機能します。ただし、エレクトロンのドキュメントに従って、フロント エンドで module.exports を使用すると、このエラーが発生します。
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);
この場合、どのように内部メソッドにアクセスすればよいですか?