ipcMain

    线程:主线程

    It is also possible to send messages from the main process to the renderer process, see [webContents.send][web-contents-send] for more information.

    • 发送消息时,事件名称为。
    • 回复同步信息时,需要设置event.returnValue
    1. //在渲染器进程 (网页) 中。
    2. const { ipcRenderer } = require('electron')
    3. console.log(ipcRenderer.sendSync('synchronous-message', 'ping')) // prints "pong"
    4. ipcRenderer.on('asynchronous-reply', (event, arg) => {
    5. console.log(arg) // prints "pong"
    6. })
    • channel String
    • channel String
      • event IpcMainEvent
      • any[]添加一次性的 listener。当且仅当下一个消息发送到 channellistener 才会被调用,随后 <0>listener</0> 会被移除。
    • channel String
    • listener Function从监听器数组中移除监听 channel 的指定 listener
    • channel String删除所有监听者,或特指的 channel 的所有监听者.

    The documentation for the event object passed to the callback can be found in the structure docs.