3

只设置了一个使用电子预构建的普通 Hello World 应用程序。我通过npm start命令运行它。

窗口按预期正常显示。但是一段时间后它会自行关闭。

在命令提示符下,它会在窗口关闭之前抛出以下警告:

WARNING:raw_channel_win.cc(473)] WriteFile: The pipe is being closed. (0xE8)
WARNING:channel.cc(549)] Failed to send message to ack remove remote endpoint (local ID 1, remote ID 1)
WARNING:channel.cc(315)] RawChannel write error

是什么导致了这个问题?

npm 版本是 1.4.10 & node (via io.js) 版本是 0.11.13 (Windows 7 x64)

4

1 回答 1

7

正如@Oztaco 所说,在快速入门指南中它具有以下代码示例:

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null;

// This method will be called when Electron has done everything
// initialization and ready for creating browser windows.
app.on('ready', function() {
  // Create the browser window.
  mainWindow = new BrowserWindow({width: 800, height: 600});

  // other code ommited

  // Emitted when the window is closed.
  mainWindow.on('closed', function() {
    // Dereference the window object, usually you would store windows
    // in an array if your app supports multi windows, this is the time
    // when you should delete the corresponding element.
    mainWindow = null;
  });
});
于 2015-06-25T21:31:53.133 回答