相关疑难解决方法(0)

Electron.remote未定义

我使用Electron时遇到了麻烦.正如你可以看到标题,当我加载远程模块时,它说它是未定义的.这是条目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
});
Run Code Online (Sandbox Code Playgroud)

我试图在这里遵循官方文件:http://electron.atom.io/docs/api/remote/

同

const { remote } = electron;
const { BrowserWindow } = remote;

let win = new BrowserWindow({width: 800, height: 600});  // error! BrowserWindow is not a constructor blabla

...
remote.getCurrentWindow().focus();
Run Code Online (Sandbox Code Playgroud)

我不知道我错过了什么.任何建议都会非常感激.

node.js electron

6
推荐指数
4
解决办法
5820
查看次数

标签 统计

electron ×1

node.js ×1