Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Electron:从浏览器窗口向Electron应用程序发送消息_Javascript_Angularjs_Electron - Fatal编程技术网

Javascript Electron:从浏览器窗口向Electron应用程序发送消息

Javascript Electron:从浏览器窗口向Electron应用程序发送消息,javascript,angularjs,electron,Javascript,Angularjs,Electron,我有一个电子应用程序,它使用浏览器窗口来显示web应用程序 我希望能够从angularjs web应用程序向Electron应用程序发送消息 我有这样的想法: //web app window.notify('message','hello'); 这可能吗?您可以使用和在主脚本和客户端脚本之间发送消息。//在渲染器进程(网页)中。const{ipcRenderer}=require('electron')console.log(ipcRenderer.sendSync('synchronou

我有一个电子应用程序,它使用
浏览器窗口
来显示web应用程序

我希望能够从angularjs web应用程序向Electron应用程序发送消息

我有这样的想法:

//web app
window.notify('message','hello');


这可能吗?

您可以使用和在主脚本和客户端脚本之间发送消息。

//在渲染器进程(网页)中。const{ipcRenderer}=require('electron')console.log(ipcRenderer.sendSync('synchronous-message','ping'))//打印“pong”ipcRenderer.on('asynchronous-reply',(event,arg)=>{console.log(arg)//打印“pong”})ipcRenderer.send('asynchronous-message,'ping')这是链接中给出的示例。我不能在我的angular应用程序中需要电子。当然,你需要在电子应用程序本身的范围内安装angular应用程序,这样你就可以使用电子功能了。我不确定是否有其他方法可以通过Electron在本地将脚本输入到你的Web应用程序中来处理这个问题,但这可能是一个太黑客了的解决方案。这就是我所担心的。
//Electron app
window.on('message',function(e){
  console.log(e.text);
};