main.js
const { app, BrowserWindow, Menu, ipcMain } = require('electron') const mainWindow = new BrowserWindow({ webPreferences: { contextIsolation: false//必须有,不然报错 } }) // 执行关闭 自定义关闭 ipcMain.on('handelClose', function (res) { app.quit() })
render.js
let close = document.getElementById('close'); close.onclick = function () { try { var ipcRender = require('electron').ipcRenderer ipcRender.send('handelClose', "执行关闭") } catch (e) { console.log("不支持ipcRenderer",e) } // alert("点击关闭") }
index.html
<div id="close">xxxxx</div> <webview class="webview" src="http://xxxx.com"></webview> <!-- You can also require other files to run in this process --> <script src="./renderer.js"></script>
标签:elecrton,const,自定义,app,关闭,close From: https://www.cnblogs.com/jqynr/p/17513226.html