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逐渐成为构建优秀交互体验应 ...
随机推荐
- Git-Git分支
代码管理之殇 分支是代码管理的利器.如果没有有效的分支管理,代码管理就适应不了复杂的开发过程和项目的需要.在实际的项目实践中,单一分支的单线开发模式还远远不够,因为: 成功的软件项目大多要经过多个开发 ...
- Django将queryset转为json对象
- (C)spring boot读取自定义配置文件时乱码解决办法
这是入门的第三天了,从简单的hello spring开始,已经慢慢接近web的样子.接下来当然是读取简单的对象属性了. 于是按照网上各位大神教的,简单写了个对象book,如上一篇(B),其他配置不需要 ...
- JavaSE总结--异常
throwable Error: Exception: 编译型异常: 运行时异常:
- C:\Windows\System32目录可执行文件列表(Win7 64)
C:\Windows\System32>where /? C:\Windows\System32>where "c:\windows\system32:*.exe" & ...
- iOS笔记061 - 二维码的生成和扫描
二维码 生成二维码 二维码可以存放纯文本.名片或者URL 生成二维码的步骤: 导入CoreImage框架 通过滤镜CIFilter生成二维码 1.创建过滤器 2.恢复滤镜的默认属性 3.设置内容 4. ...
- 最小化安装Linux的常用配置整理
基于安全性考虑,将服务器进行最小化安装,毕竟软件包越少,漏洞越少,相对来说就约安全,但是最小化安装会给运维带来一些问题和不便,下面是我总结的,常见的一些配置和工具的安装,仅供各位大神参考,如有新的id ...
- 剑指offer-从尾到头打印链表03
class Solution: # 返回从尾部到头部的列表值序列,例如[1,2,3] def printListFromTailToHead(self, listNode): # write code ...
- 数据结构与算法之顺序表C语言实现
顺序表等相关概念请自行查阅资料,这里主要是实现. 注: 1.顺序表C语言实现: 2.按较简单的方式实现,主要帮助理解,可在此基础上修改,更加完善: 3.提供几个简单函数,可自行添加功能: 4.可用C+ ...
- 深入理解css之float
1.float的历史 float的设计的初衷:文字环绕效果 2.包裹与破坏 增强浮动的感性认知 包裹:1.收缩 2.坚挺 3.隔绝 里面的布局和外面一点关系都没有 包裹的特性就是BFC block f ...