1
主進程打開到渲染器需要訪問的服務的連接。電子:renderer訪問主進程?
這可能嗎?
我試過聲明global.thing
和exports.thing
,並且具有渲染require('electron').remote.thing
- 這裏就是一個函數或標量 - 但沒有運氣。
主進程打開到渲染器需要訪問的服務的連接。電子:renderer訪問主進程?
這可能嗎?
我試過聲明global.thing
和exports.thing
,並且具有渲染require('electron').remote.thing
- 這裏就是一個函數或標量 - 但沒有運氣。
你可以做更多的方式:
1)進程之間通信的IPC與ipcRenderer.sendSync功能,即要求主工藝要求的數據和等待返回值。 https://github.com/electron/electron/blob/master/docs/api/ipc-renderer.md
2)使用出口以正確的方式,因此:
的主要工序:
exports.functionName = functionName;
中渲染:
var functionName = remote.require('./main').functionName;
試過後者 - 現在我明白了錯字:謝謝。 – LeeGee
@ emish89:你可以請看看http://stackoverflow.com/questions/41485770/access-a-function-in-main-window-from-renderer-process-in-electron?noredirect=1#comment70204002_41485770 –