【发布时间】:2016-06-12 10:36:06
【问题描述】:
今天刚开始学习 Electron。
我不太了解,但我认为:
- Electron 是一种类似于 C# 的语言。
- Atom 是一个类似于 notepad++ 的文本编辑器。
在 Atom.io 中,我创建了一个名为 Demo 的文件夹,其中包含以下 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
【问题讨论】:
-
Electron 是用 node.js 写的,安装 node.js 就大功告成了
-
@MassimilianoArione 如何安装 node.js??
-
官网下载nodejs.org/en
-
@MassimilianoArione 我已经从您建议的链接中安装了 Node.js。现在我该如何运行我的项目??
标签: electron atom-editor