Angular2 和电子访问 browserWindwow 对象
Angular2 and electron accessing browserWindwow object
我正在将 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。
目的是打开一个新的浏览器window对象,就像这里所做的那样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});
我正在将 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。
目的是打开一个新的浏览器window对象,就像这里所做的那样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});