我正在尝试在 Electron JS 应用程序的无框窗口上添加关闭和最小化按钮。但无论如何它都不起作用。它总是显示“无法读取未定义的属性'getCurrentWindow'”错误。这是我的代码:
const {remote} = require('electron');
document.getElementById('minimize').onclick = function() {
var window = remote.getCurrentWindow();
window.minimize();
}
document.getElementById('close').onclick = function() {
var window = remote.getCurrentWindow();
window.close();
}
Run Code Online (Sandbox Code Playgroud)
我还在 main.js 中添加了 webPreferences: {nodeIntegration: true}。
win = new BrowserWindow({width: 990, height: 660, title: "Okkhor52 Tools", show: false, resizable: false, frame: false, webPreferences: {nodeIntegration: true}});
Run Code Online (Sandbox Code Playgroud)
请给我一个解决方案,我试图在很多地方找到这个问题的解决方案,但我没有得到确切的解决方案。