How to pass parameters from main process to render processes in Electron

前端 未结 7 854
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 02:30

I have an Electron app that can open different windows.

On app launch the app open a set of window(s) (that load the same HTML and JS files) but with params to change ea

7条回答
  •  醉酒成梦
    2021-02-13 02:31

    For example:

    Process script

    In your main script write:

    global.varsForWindow = {
        platform: process.platform
    };
    

    Window script

    Where you need it in a window script:

    var varsFromMainScript = require('electron').remote.getGlobal('varsForWindow');
    console.log(varsFromMainScript.platform);
    

提交回复
热议问题