0
需求:電子渲染過程cannt使用ipcRenderer.send()
渲染過程需要將數據發送到主進程。
我的代碼:
//index.js (renderer process)
const {ipcRenderer} = require('electron')
class WebWindow {
constructor() {
...
setInterval(() => {
this.foo()
}, 2000)
// or
let that = this
setInterval(function() {
thar.foo()
}, 2000)
}
foo() {
data = {}
ipcRenderer.send('async-cookies', data)
}
}
問題 我得到的錯誤:
Uncaught Exception:
TypeError: Cannot read property 'send' of undefined
at Function.eval
Semms cannt中的setInterval使用IPC?
我該怎麼辦..
謝謝!
使用箭頭函數時,您不需要播放這個/那個/自我重新聲明遊戲,並且您的代碼不顯示該聲明? –
我編輯過。這兩個代碼我都試過了.. – steve