I have trouble with using Electron. As you can see the title, when i load remote module, it saids it is undefined. This is the code of entry js:
const electron = require('electron');
const { app, BrowserWindow, Tray, remote, ipcMain } = electron;
function initApp() { ... }
app.on('ready', () => {
initApp();
console.log(electron); // object, but no remote inside
console.log(electron.remote); // undefined
console.log(remote); // undefined
});
and i tried to follow official doc here: http://electron.atom.io/docs/api/remote/
with
const { remote } = electron;
const { BrowserWindow } = remote;
let win = new BrowserWindow({width: 800, height: 600}); // error! BrowserWindow is not a constructor blabla
...
remote.getCurrentWindow().focus();
i don't know what am i missing. any advice will very appreciate.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…