const { remote } = require('electron') window.addEventListener('DOMContentLoaded', () => { let oBtn = document.getElementById('btn') oBtn.addEventListener('click', () => { let subWin = new remote.BrowserWindow({ width: 200, height: 200, parent: remote.getCurrentWindow(), // 设置父窗口 modal: true, // 设置模态窗口 }) subWin.loadFile('sub.html') subWin.on('close', () => { subWin = null }) }) })