electron入门学习文档.ppt_第1页
electron入门学习文档.ppt_第2页
electron入门学习文档.ppt_第3页
electron入门学习文档.ppt_第4页
electron入门学习文档.ppt_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、electron,环境安装,第一步安装Node.js 然后使用NPM全局安装electron npm i electron -g,Quick start,项目大致的文件结构如右图所示 package.json是node项目的配置文件 main.js是electron的入口 index.html就是应用的文件,package.json name : your-app, /应用名称 version : 0.1.0, /版本号 main : main.js /electron的入口文件 ,const app, BrowserWindow = require(electron) let win fun

2、ction createWindow () win = new BrowserWindow(width: 800, height: 600) / Create the browser window. win.loadURL(file:/$_dirname/html/login.html)/ and load the index.html of the app. win.webContents.openDevTools() / Open the DevTools. win.on(closed, () = win = null ) app.on(ready, createWindow),app.o

3、n(window-all-closed, () = / On macOS it is common for applications and their menu bar / to stay active until the user quits explicitly with Cmd + Q if (process.platform != darwin) app.quit() ) app.on(activate, () = / On macOS its common to re-create a window in the app when the / dock icon is clicke

4、d and there are no other windows open. if (win = null) createWindow() ), Hello World! Hello World! We are using node document.write(process.versions.node), Chrome document.write(process.versions.chrome), and Electron document.write(process.versions.electron). ,运行,用CMD转到项目文件下运行 electron .,electron 和

5、jquery 冲突解决方案,1 手动导入$ window.$ = window.jQuery = require(jquery.js); 2 在导入前后添加代码 if (typeof module = object) window.module = module; module = undefined; if (window.module) module = window.module; ,使用node拓展,以Serialport为例 在项目下运行 npm install Serialport -save-dev 在JS中直接调用 var SerialPort = require(serial

6、port); SerialPort.list(err, ports) = ports.forEach(port) = console.log(Name); ) );,由于serialport是依赖C的插件,所以没有以electron版本编译会报错,首先全局安装node-gyp npm install node-gyp -g 转到serialport目录下 cd node_modules/serialport 然后编译 node-gyp rebuild -target=1.4.6 -arch=ia32 -dist-url=https:/atom.io/download/atom-shell,打包,使用electron-packager来打包,electron-packager ./app HelloWorld -out ./OutApp -pla

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论