河北保定网站建设,石家庄网站建设找汉狮,网站建设工作半年通报,北京公司有哪些主进程与渲染进程之间的通信
这是渲染进程
// 渲染进程执行主进程里面的方法#xff0c;主进程给渲染进程反馈处理结果 。
var sendreplayDomdocument.querySelector(#sendreplay);
sendreplayDom.onclickfunction(){// alert(1213)//渲染进程给主进程广播数据ipcRenderer.se…主进程与渲染进程之间的通信
这是渲染进程
// 渲染进程执行主进程里面的方法主进程给渲染进程反馈处理结果 。
var sendreplayDomdocument.querySelector(#sendreplay);
sendreplayDom.onclickfunction(){// alert(1213)//渲染进程给主进程广播数据ipcRenderer.send(sendreplay,this is renderer aaa);
}
//接收主进程广播的事件
ipcRenderer.on(replay,function(event,data){console.log(data);
})这是主进程
//接收广播 并且返回处理结果
ipcMain.on(sendreplay,function(event,data){console.log(data);// console.log(event);//主进程给渲染进程广播数据event.sender.send(replay,ok haha);
})渲染进程与渲染进程之间的通信
a.渲染进程 openWindows.js
btn.onclickfunction(){// alert(点击了);var aid12345678;ipcRenderer.send(openWindow,aid);
}
//接收news 传过来的数据
ipcRenderer.on(toIndex,function(event,data){console.log(data)
})b.主进程 ipcMain.js
ipcMain.on(openWindow,function(event,aid){//1.获取当前窗口的对象 var winIdBrowserWindow.getFocusedWindow().id;//调用 BrowserWindow打开新窗口winnew BrowserWindow({width:400,height:300,webPreferences:{nodeIntegration: true}// frame:false,// fullscreen:true})win.loadURL(path.join(file:,__dirname,../news.html));//开启新窗口的调试模式win.webContents.openDevTools();//通过win.webContents.send把当前数据广播给 news进程win.webContents.on(did-finish-load,function(){win.webContents.send(toNews,aid,winId);})win.on(closed,(){winnull;})
})c. 渲染进程 new.js
ipcRenderer.on(toNews,function(event,aid,winId){// winId 第一个窗口的id//获取 对应id的窗口console.log(aid);var firstWinBrowserWindow.fromId(winId);firstWin.webContents.send(toIndex,this is news);
})