Electron学习(5)BrowserWindow模块

2017-10-29  本文已影响565人  叶小七的真命天子

创建和控制浏览器窗口。
需要注意的是,在主进程和渲染进程调用的方式不一样
在主进程中直接调用:const {BrowserWindow} = require('electron')
在渲染进程中则需使用remote来调用:const {BrowserWindow} = require('electron').remote

// 在主进程中
const {BrowserWindow} = require('electron')

// 或者在渲染进程中使用 `remote`
// const {BrowserWindow} = require('electron').remote

let win = new BrowserWindow({width: 800, height: 600})
win.on('closed', () => {
  win = null
})

// 加载一个远程地址
win.loadURL('https://github.com')

// 或者加载一个本地文件
win.loadURL(`file://${__dirname}/app/index.html`)

一、new BrowserWindow([options])的配置项

二、事件

上一篇 下一篇

猜你喜欢

热点阅读