【发布时间】:2017-07-06 04:40:06
【问题描述】:
在我的主进程中,我创建了一个渲染器窗口:
var mainWindow = new BrowserWindow({
height: 600,
width: 800,
x: 0,
y: 0,
frame: false,
resizable: true
});
mainWindow.openDevTools();
mainWindow.loadURL('file://' + __dirname + '/renderer/index.html');
那我想通过某种方式与它交流:
mainWindow.webContents.send('message', 'hello world');
但是主窗口没有收到此消息,因为在我尝试发送它时它还没有完全创建。
我通过将后面的代码包装在 setTimeout() 中暂时解决了这个问题,但这绝对不是解决竞争条件的正确方法。
主窗口准备就绪时是否有回调?我尝试了文档中提到的“ready-to-show”事件,但没有成功。
【问题讨论】:
标签: electron