我尝试了以下代码来关闭Electron JS中的无框架窗口。但是单击按钮时窗口不会关闭。我是Electron的新手,现在被困在这里。
const electron = require('electron');
const path = require('path');
const remote = electron.remote;
const closeBtn = document.getElementById('closeBtn');
closeBtn.addEventListener('click', function(event) {
var window = remote.getCurrentWindow();
window.close();
});
请告诉我我现在应该做什么。提前致谢...
最佳答案
我解决了问题。我必须将以下属性添加到新的BrowserWindow声明中。
webPreferences: {
nodeIntegration: true
}
尽管对于较旧的版本不是必需的,但对于较新的版本则是必需的。
关于javascript - 在Electron JS中无法使用 Remote 关闭窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63004221/