electron 安装使用
1.安装 node.js
链接:http://pan.baidu.com/s/1o7W7BIy 密码:y6od
一路next
我安装在F:\Program Files\node.js下
2.检查node.js和npm是否安装成功
- 命令行:node -v
- 命令行:npm -v

建议把npm的仓库切换到国内taobao仓库,
注册cnpm命令,如下
npm install -g cnpm --registry=https://registry.npm.taobao.org

3. Electron的安装
cnpm install -g electron

electron是否安装成功可通过命令 electron -v 查看。

4. 打包输出工具
cnpm install -g electron-packager

5.electron 客户端工具
Electron.exe
链接:http://pan.baidu.com/s/1mieJnLI 密码:x2i8
安装完成双击electron.exe文件

6.新建一个程序
新建一个文件夹,命名为electron,在文件夹目录下,创建三个文件,package.json,main.js,index.html
文件夹目录的结构如下:
package.json
1 {
2 "name" : "your-app",
3 "version" : "0.1.0",
4 "main" : "main.js"
5 }
6
7
main.js
1 const electron = require('electron');
2 // Module to control application life.
3 const {app} = electron;
4 // Module to create native browser window.
5 const {BrowserWindow} = electron;
6
7 // Keep a global reference of the window object, if you don't, the window will
8 // be closed automatically when the JavaScript object is garbage collected.
9 let win;
10
11 function createWindow() {
12 // Create the browser window.
13 win = new BrowserWindow({width: 800, height: 600});
14
15 // and load the index.html of the app.
16 win.loadURL(`file://${__dirname}/index.html`);
17
18 // Open the DevTools.
19 win.webContents.openDevTools();
20
21 // Emitted when the window is closed.
22 win.on('closed', () => {
23 // Dereference the window object, usually you would store windows
24 // in an array if your app supports multi windows, this is the time
25 // when you should delete the corresponding element.
26 win = null;
27 });
28 }
29
30 // This method will be called when Electron has finished
31 // initialization and is ready to create browser windows.
32 // Some APIs can only be used after this event occurs.
33 app.on('ready', createWindow);
34
35 // Quit when all windows are closed.
36 app.on('window-all-closed', () => {
37 // On OS X it is common for applications and their menu bar
38 // to stay active until the user quits explicitly with Cmd + Q
39 if (process.platform !== 'darwin') {
40 app.quit();
41 }
42 });
43
44 app.on('activate', () => {
45 // On OS X it's common to re-create a window in the app when the
46 // dock icon is clicked and there are no other windows open.
47 if (win === null) {
48 createWindow();
49 }
50 });
51
52 // In this file you can include the rest of your app's specific main process
53 // code. You can also put them in separate files and require them here.
index.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="UTF-8">
5 <title>Hello World!</title>
6 </head>
7 <body>
8 <h1>Hello World!</h1>
9 We are using node <script>document.write(process.versions.node)</script>,
10 Chrome <script>document.write(process.versions.chrome)</script>,
11 and Electron <script>document.write(process.versions.electron)</script>.
12 </body>
13 </html>
7.运行程序
两种方法
1.命令行
在cmd里面写

Electron.exe安装路径

自己的文件夹的路径



2.拖
把你写的文件夹直接拖到electron.exe里面。


electron 安装使用的更多相关文章
- electron 安装
1.从网上下载的是nodejs的v0.10.42版本的安装文件,安装node-v0.10.42-x86.msi都使用默认安装,安装完成后会安装在C:\Program Files\nodejs\目录下, ...
- Electron安装过程深入解析(读完此文解决Electron应用无法启动,无法打包的问题)
1. 安装Electron依赖包 开发者往往通过npm install(或 yarn add)指令完成为Node.js工程安装依赖包的工作, 安装Electron也不例外,下面是npm和yarn的安装 ...
- Electron安装
1.安装nodejs和npm 官网下载地址:https://nodejs.org/en/download/ 安装包:下载.msi 安装完成后: nodejs.npm都会安装好,path环境变量也自动设 ...
- electron安装+运行+打包成桌面应用+打包成安装文件+开机自启动
1.初始化node项目,生成package.json文件 npm init 2.安装electron,并保存为开发依赖项 npm install electron -D 3.根目录下新建index.j ...
- electron安装到第一个实例
1.node.js下载,然后安装.下载地址:链接:http://pan.baidu.com/s/1o7TONhS 密码:fosa 2.cmd下输入:npm install electron-prebu ...
- Electron 安装与使用
Electron是使用 JavaScript, HTML 和 CSS 构建跨平台的桌面应用 本文基于Windows进行开发的过程,记录下来,以便日后使用,Electron官网:https://elec ...
- electron安装与使用
系统 WIN10 X64 1. python-2.7.15.amd64.msi 2. node-v10.4.1-x64.msi 3. VS2015 community(社区版) 4. npm conf ...
- electron 安装失败解决办法
1.安装node https://nodejs.org/en/download/2.安装镜像工具npm install -g cnpm --registry=https://registry.npm. ...
- 为Electron 安装 vue-devtool等扩展
相关代码: https://github.com/WozHuang/Barrage-helper/blob/master/src/main/index.dev.js 在SPA逐渐成为构建优秀交互体验应 ...
随机推荐
- 笔记-python-standard library-17.7 queue
笔记-python-standard library-17.7 queue 1. queue source code:Lib/queue.py 该模块实现了多生产者,多消费者队列. 此模块实现了所有 ...
- 十二、mysql之视图,触发器,事务等
一.视图 视图是一个虚拟表(非真实存在),其本质是[根据SQL语句获取动态的数据集,并为其命名],用户使用时只需使用[名称]即可获取结果集,可以将该结果集当做表来使用. 使用视图我们可以把查询过程中的 ...
- 6,MongoDB 之 Array Object 的特殊操作
相比关系型数据库, Array [1,2,3,4,5] 和 Object { 'name':'DragonFire' } 是MongoDB 比较特殊的类型了 特殊在哪里呢?在他们的操作上又有什么需要注 ...
- HDU 5293 Tree chain problem 树形DP
题意: 给出一棵\(n\)个节点的树和\(m\)条链,每条链有一个权值. 从中选出若干条链,两两不相交,并且使得权值之和最大. 分析: 题解 #include <cstdio> #incl ...
- Codeforces 771E Bear and Rectangle Strips DP
题意: 一个由大写字母组成的长度为\(n(n \leq 75)\)的字符串,每次操作可以交换相邻位置的两个字母,求最少操作多少次使字符串中不出现子串VK 分析: VK之外的字母具体是什么,我们并不关心 ...
- Python的类(一)
类(Class): 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例. 类变量:类变量在整个实例化的对象中是公用的.类变量定义在类中且在函数体之外. ...
- Pascal ASCII和文本的转换
用于帮助新手理解ASCII码和字符型与整型的一段小程序,转载请注明出处 例如:输入 I love you 打印 73 32 108 111 118 101 32 121 111 117 13 10 P ...
- python学习笔记十七:base64及md5编码
一.Python Base64编码 Python中进行Base64编码和解码要用base64模块,代码示例: #-*- coding: utf-8 -*- import base64 str = 'c ...
- Python 3基础教程2-打印语句和字符串
本文介绍Python 3中的打印语句和字符串使用,具体练习请看下面的demo.py print ('Hello Python 3!') """文本讲打印语句和字符串打印语 ...
- CodeForces-1061D TV Shows
题目链接 https://vjudge.net/problem/CodeForces-1061D 题面 Description There are nn TV shows you want to wa ...