electron入门学习文档.ppt

上传人:小飞机 文档编号:5428805 上传时间:2023-07-06 格式:PPT 页数:14 大小:235.99KB
返回 下载 相关 举报
electron入门学习文档.ppt_第1页
第1页 / 共14页
electron入门学习文档.ppt_第2页
第2页 / 共14页
electron入门学习文档.ppt_第3页
第3页 / 共14页
electron入门学习文档.ppt_第4页
第4页 / 共14页
electron入门学习文档.ppt_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《electron入门学习文档.ppt》由会员分享,可在线阅读,更多相关《electron入门学习文档.ppt(14页珍藏版)》请在三一办公上搜索。

1、electron,环境安装,第一步安装Node.js然后使用NPM全局安装electronnpm 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 winfunction createWindow()w

2、in=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.on(window-all-closed,()=/On macOS it is commo

3、n 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 clicked and there are no other windows open.if(win=null)createWindow(),

4、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 和 jquery 冲突解决方案,1 手动导入$window.$=window.jQuery=require(jquery.js);2 在导入前后添加代码 if(ty

5、peof module=object)window.module=module;module=undefined;if(window.module)module=window.module;,使用node拓展,以Serialport为例在项目下运行 npm install Serialport-save-dev在JS中直接调用var SerialPort=require(serialport);SerialPort.list(err,ports)=ports.forEach(port)=console.log(Name););,由于serialport是依赖C的插件,所以没有以electron

6、版本编译会报错,首先全局安装node-gypnpm 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-platform=win32-arch=ia32-electron-version=1.4.6-asar参数分别是项目路径 项目名称 输出路径 操作系统 操作系统位数 electron 版本,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号