Electron Github developed by the open source framework
that allows developers to use Web technologies to build desktop applications cross-platform
Electron = Chromium + Node.js + Native API
You must first go to the installation node environment
official website address: https: //nodejs.org/zh-cn/
Next to begin the installation Electron
cnpm install -g electron
To use cnpm here already installed, if you want to use to install npm will be particularly slow, unless over the wall
Initiate a project
to create a new file on your desktop
- create a html file
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> Hello there </body> </html>
Create a js file
const electron = require ( 'electron') // introducing electron module var app = electron.app // create electron references var BrowserWindow = electron.BrowserWindow; // create the window reference var mainWindow = null; // declaration of the main window to open app.on('ready', () => { mainWindow = new BrowserWindow({ width: 900, height: 900 Size}) // Set the window mainWindow.loadFile ( 'index.html'); // file to be loaded // listen for close event, in the main window, set bit null mainWindow.on('closed', () => { mainWindow = null; }) })
After writing direct npm init --yes to initialize package.json file
to run the project
directly in the console input
electron .
You can be opened
Environment is already set up and use electron