Javascript 未捕获异常:尝试在已关闭或释放的渲染器窗口中调用函数

Javascript 未捕获异常:尝试在已关闭或释放的渲染器窗口中调用函数,javascript,node.js,electron,ipc,Javascript,Node.js,Electron,Ipc,我是桌面应用程序开发新手,正在使用Electron和node.js以及javascript构建我的应用程序。以下是我试图实现的目标的简短描述: FirstWindow.html 具有与事件侦听器双击关联的每个列表项的产品列表。双击任何元素时 SecondWindow.html 应该创建,其中包含从数据库(postgesql)获取的已单击产品的信息。但在打开应用程序时,我发现以下错误: 未捕获异常:尝试在已关闭或释放的渲染器窗口中调用函数 下面是我的代码片段,我在其中尝试实现ipcMain

我是桌面应用程序开发新手,正在使用Electron和node.js以及javascript构建我的应用程序。以下是我试图实现的目标的简短描述:

  • FirstWindow.html

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

  • SecondWindow.html

    应该创建,其中包含从数据库(postgesql)获取的已单击产品的信息。但在打开应用程序时,我发现以下错误:

未捕获异常:尝试在已关闭或释放的渲染器窗口中调用函数

下面是我的代码片段,我在其中尝试实现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>
<script>
const { ipcRenderer } = require('electron');
ipcRenderer.on('item_action_to_be_done', (event, item) => {
console.log(item);
});
</script>

const{ipcrender}=require('electron');
ipcRenderer.send('item\u catch\u in\u main',productname);
SecondWindow.html

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

const{ipcrender}=require('electron');
ipcRenderer.on('item\u action\u to\u be\u done',(event,item)=>{
控制台日志(项目);
});

如果有人在Elecrton解决过类似问题,请告诉我。提前谢谢

这是一个老帖子,但你有没有找到解决办法?