我目前对electron.js及其模块授予的全面机会感兴趣。不幸的是,尝试启动我的应用程序时,我在渲染器进程中一直遇到相同的错误(名为“connector.js”)。
这是错误:
App threw an error during load
TypeError: Cannot match against 'undefined' or 'null'.
at Object.<anonymous> (D:\Eigene Dateien\Desktop\Coding\DesktopApps\EVT\extFunctions\connector\connector.js:2:44)
at Object.<anonymous> (D:\Eigene Dateien\Desktop\Coding\DesktopApps\EVT\extFunctions\connector\connector.js:22:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\Eigene Dateien\Desktop\Coding\DesktopApps\EVT\main.js:9:1)
这是我的connector.js:
const $ = require('jquery');
const {BrowserWindow} = require('electron').remote;
let Remotewin = remote.getFocusedWindow();
$("#minimize").click(function(){
Remotewin.minimize();
});
$("#maximize").click(function(){
if(!Remotewin.isMaximized()){
Remotewin.maximize();
}else{
Remotewin.unmaximize();
}
});
$("#close").click(function(){
Remotewin.close();
});
正如您可以清楚地看到的那样,我想在窗口的顶部框架中创建自己的菜单栏,但是此错误似乎使功能被取消了。我已经搜索了一半的互联网和stackoverflow,但是我发现的每个答案都是针对它们无法直接影响的webpack和/或 Electron 错误。
这就是为什么我要明确指出的原因,即我不在此项目中使用webpack。正如您在代码中看到的,只有我添加的外部模块是jquery。
所以我的问题;您是否在这种情况下遇到了此错误,甚至还知道解决方案?还是您可以指称有类似问题的人?
预先谢谢你,J0nny
最佳答案
由于getFocusedWindow()是BrowserWindow的静态方法,
let Remotewin = remote.getFocusedWindow();
应该:
let Remotewin = BrowserWindow.getFocusedWindow();
关于javascript - 远程函数在 Electron 渲染器过程中返回undefined或null,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48366400/