最初のプログラム
main.js
const { app, BrowserWindow } = require("electron");
let win;
function createWindow() {
win = new BrowserWindow({ width: 800, height: 600});
// index.html をロード
win.loadURL(`file://${__dirname}/index.html`);
win.on("closed", () => { win = null; });
}
app.on("ready", createWindow);
app.on("window-all-closed", () => {
// Mac以外
if(process.platform !== "darwin") {
app.quit();
}
});
app.on("activate", () => {
if(win === null) {
createWindow();
}
});
■アロー関数
ES2015の新構文: 「アロー関数」は無名関数の省略記法です。
無名関数 引数が無し
var fn = function () {/* 関数本体 */};
アロー関数
var fn = () => {/* 関数本体 */};
■比較演算子
== 等価演算子
数値と文字列を比較するとき、文字列は数値に変換されます。
=== 厳密等価演算子
型を含めた比較を行います。
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Electron Test</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
実行
node_modules\.bin\electron .