今天我刚刚开始学习Electron。如何运行电子项目
我没有更多的了解,但我认为:
- 电子是像C#语言。
- Atom是一个类似于notepad ++的文本编辑器。
里面Atom.io我创建了一个文件夹,名为演示它有3个文件,如下所示:
Demo
|--package.json
|--main.js
|--index.html
在的package.json:
{
"name" : "Demo",
"version" : "0.1.0",
"main" : "main.js"
}
在main.js:
const electron = require('electron');
const {app} = electron;
const {BrowserWindow} = electron;
let win;
function createWindow() {
win = new BrowserWindow({width: 800, height: 600});
win.loadURL(`file://${__dirname}/index.html`);
win.webContents.openDevTools();
win.on('closed',() => {
win = null;
});
}
app.on('ready', createWindow);
// Quit when all windows are closed.
app.on('window-all-closed',() => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate',() => {
if (win === null) {
createWindow();
}
});
在index.html中:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
现在,我想知道我该如何运行此项目?我需要安装其他任何软件来运行它吗?
我使用Windows 8.1
电子是用node.js写的,安装节点。js和你完成了 –
@MassimilianoArione如何安装node.js? – Vishal
从官方网站下载https://nodejs.org/en/ –