Javascript Can';t使用IPC与electronjs angularjs通信

Javascript Can';t使用IPC与electronjs angularjs通信,javascript,angularjs,electron,webkit,desktop-application,Javascript,Angularjs,Electron,Webkit,Desktop Application,我从electronjs桌面应用程序开始,所以我决定使用angularjs进行查看 现在,当我尝试使用eletron ipc在这两者之间进行通信时,我发现无法读取未定义的属性“send” 这就是我到目前为止所做的: main.js——electronjs app.controller.js——angularjs 我显然做错了什么,有人能帮我一下吗?明白了 在main.js中创建浏览器窗口时将节点集成设置为true win = new BrowserWindow({ show: false, we

我从electronjs桌面应用程序开始,所以我决定使用angularjs进行查看

现在,当我尝试使用eletron ipc在这两者之间进行通信时,我发现无法读取未定义的属性“send”

这就是我到目前为止所做的:

main.js——electronjs app.controller.js——angularjs
我显然做错了什么,有人能帮我一下吗?

明白了

main.js中创建浏览器窗口时将节点集成设置为true

win = new BrowserWindow({
show: false,
webPreferences: {
    nodeIntegration: true
  }
});
这允许angularjs使用require(),所以在app.controller.js中我就这么做了

const { ipcRenderer } = require('electron')
  // In renderer process (web page).
  console.log(ipcRenderer.sendSync('synchronous-message', 'ping')) // prints "pong"

  ipcRenderer.on('asynchronous-reply', (event, arg) => {
    console.log(arg) // prints "pong"
  })
  ipcRenderer.send('asynchronous-message', 'ping')
}
因此,它会在控制台中打印: 庞
pong

是一个基本元素,因此没有属性。这就是为什么它没有
send
属性的原因。代码应该避免在没有赋值的情况下访问变量的属性。我知道。我需要的是有人指导我如何在electron和angularjs之间建立通信。
win = new BrowserWindow({
show: false,
webPreferences: {
    nodeIntegration: true
  }
});
const { ipcRenderer } = require('electron')
  // In renderer process (web page).
  console.log(ipcRenderer.sendSync('synchronous-message', 'ping')) // prints "pong"

  ipcRenderer.on('asynchronous-reply', (event, arg) => {
    console.log(arg) // prints "pong"
  })
  ipcRenderer.send('asynchronous-message', 'ping')
}