最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Electron: renderer access to main process? - Stack Overflow

programmeradmin3浏览0评论

The main process opens a connection to a service, to which a renderer requires access.

Is this possible?

I've tried declaring global.thing and exports.thing, and having the renderer require('electron').remote.thing — where thing is a function or scalar — but no luck.

The main process opens a connection to a service, to which a renderer requires access.

Is this possible?

I've tried declaring global.thing and exports.thing, and having the renderer require('electron').remote.thing — where thing is a function or scalar — but no luck.

Share Improve this question asked Dec 15, 2016 at 14:42 Lee GoddardLee Goddard 11.2k5 gold badges51 silver badges69 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

You can do it in more ways:

1) Communicate between process with ipc and ask data with ipcRenderer.sendSync function, that asks to main process and wait for a return value. https://github./electron/electron/blob/master/docs/api/ipc-renderer.md

2) use exports in the right way, so:

in the main process:

exports.functionName = functionName;

in the renderer:

var functionName = remote.require('./main').functionName;
发布评论

评论列表(0)

  1. 暂无评论