多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## ipcMain 与 ipcRenderer 进程间的通讯 [https://electronjs.org/docs/api/ipc-renderer](https://electronjs.org/docs/api/ipc-renderer) ``` ipcRenderer.on(channel, listener) ipcRenderer.once(channel, listener) 只地监听一次后删除 ipcRenderer.removeAllListeners(channel) ipcRenderer.send(channel[, arg1][, arg2][, ...]) ``` main.js ``` //ipcMain 处理 ipcMain.on("main_liston",(event,arg)=>{ console.log(arg); event.sender.send("renderer_liston",'main to renderer') }) ``` other.js ``` const {ipcRenderer} = require('electron'); ipcRenderer.send('main_liston',`renderer to main num:`); ipcRenderer.on('renderer_liston',(event,arg)=>{ //arg }) ```