我将 Angular2 与 Electron 和 WebPack 结合使用。
我正在尝试获取 BrowserWindow
对象 https://github.com/atom/electron/blob/master/docs/api/browser-window.md
我正在我的组件顶部做
import * as electron from 'electron';
但是在做时:
this.authWindow = new electron.BrowserWindow({ width: 800, height: 600, show: false});
我在运行时遇到错误
ORIGINAL EXCEPTION: TypeError: electron.BrowserWindow is not a function
当记录 Electron 本身时,它看起来只是一个函数,因此其中没有 BrowserWindow
对象。
function defineProgram(name, opts) {
var program = new Program(name, opts);
return program;
}
在 WebPack 中,我使用 webpackTargetElectronRenderer
来定位 Electron。
目的是打开一个新的浏览器窗口对象,就像这里所做的那样 http://manos.im/blog/electron-oauth-with-github/
最佳答案
要在渲染器进程和主进程之间进行通信,您需要使用Remote
API ( https://github.com/atom/electron/blob/master/docs/api/remote.md )。
这样的事情应该有效:
const remote = require('electron').remote;
const BrowserWindow = remote.BrowserWindow;
this.authWindow = new BrowserWindow({ width: 800, height: 600, show: false});
关于javascript - Angular2和Electron访问browserWindwow对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36113254/