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

前端 未结 7 847
隐瞒了意图╮
隐瞒了意图╮ 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:58

    According atom source code the query string method is a reliable way to do that very simply, especially when we only need to pass a unique string param:

    // main process
    win1.loadURL(`file://${__dirname}/app/app.html?id=${id}`);
    
    // rendered process
    console.log(global.location.search);
    

    https://github.com/electron/electron/issues/6504

提交回复
热议问题