未捕获的exception:试图在已经closures或释放的渲染器窗口中调用一个函数

我是新来的桌面应用程序开发,并使用电子node.js和JavaScript来构build我的应用程序。 这里是我想要实现的一个简短的描述:

  • FirstWindow.html

    具有与每个与事件监听器双击相关联的列表项目的产品列表。 双击任何元素。

  • SecondWindow.html

    应该被创build,它具有从数据库(postgesql)中提取的点击产品的信息。 但是在打开应用程序时出现以下错误:

未捕获exception:试图在已closures或释放的渲染器窗口中调用函数

这里是我的代码片段,我试图实现ipcMain和ipcRenderer模块:

main.js

const electron = require('electron'); ipcMain.on('item_catch_in_main', function(e, productname){ SecondWindow.webContents.send('item_action_to_be_done', productname); }); 

FirstWindow.html

 <script> const { ipcRenderer } = require('electron'); ipcRenderer.send('item_catch_in_main', productname); </script> 

SecondWindow.html

 <script> const { ipcRenderer } = require('electron'); ipcRenderer.on('item_action_to_be_done', (event, item) => { console.log(item); }); </script> 

请让我知道是否有人在Elecrton解决了类似的问题。 提前致谢!