【问题标题】:Sending a message to the parent window in Electron在 Electron 中向父窗口发送消息
【发布时间】:2017-11-22 13:40:38
【问题描述】:

我有一个渲染进程打开一个模态窗口

import { remote } from 'electron';

let currentWindow = remote.getCurrentWindow();
let modalWindow = new BrowserWindow({width:800, heigh:500, parent:currentWindow});
modalWindow.loadURL('views/second.html');

如何将消息modalWindow 传回其父级?

【问题讨论】:

    标签: node.js electron ipc modal-window


    【解决方案1】:

    你必须使用ipc通信。

    在主进程中:

    ipcMain.on('asynchronous-message', (event, arg) => {
       //manage data
    })
    

    在你的模态窗口中:

    ipcRenderer.send('asynchronous-message', message)
    

    ipcMain doc

    ipcRenderer doc

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-05
      • 2019-01-18
      • 1970-01-01
      • 2017-12-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多