index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Hello Document</title> </head> <body> Hello Document </body> </html>
main.js
//引入electron模块,app和网页窗口 var electron = require('electron'); var app = electron.app var BrowserWindow = electron.BrowserWindow var mainWindow = null //声明主窗口 app.on('ready', ()=>{ //创建主窗口并设置加载的网页文件 mainWindow = new BrowserWindow({width:800, height:800}) mainWindow.loadFile('index.html') mainWindow.on('closed', ()=>{ //当主窗口退出时,释放mainWindow mainWindow = null }) })
然后键入nmp init --yes 来生成package.json
全局安装时键入electron . 来启动
局部安装时键入./node_modules/.bin/electron . 来启动
标签:app,mainWindow,BrowserWindow,electron,var,Hello From: https://www.cnblogs.com/anzf/p/17044727.html