[英]Unable to Close Window using remote in Electron JS
我尝试使用以下代码关闭 Electron JS 中的无框 window。 但是单击按钮时 window 不会关闭。 我是 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
}
尽管对于旧版本没有必要,但对于较新的版本是必要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.