electron入门学习文档

上传人:xiao****1972 文档编号:245031294 上传时间:2024-10-07 格式:PPT 页数:14 大小:235.99KB
返回 下载 相关 举报
electron入门学习文档_第1页
第1页 / 共14页
electron入门学习文档_第2页
第2页 / 共14页
electron入门学习文档_第3页
第3页 / 共14页
点击查看更多>>
资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,*,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,function 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.on(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 clicked 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,和,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(serialport);,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-platform=win32-arch=ia32-electron-version=1.4.6,-asar,参数分别是,项目路径 项目名称 输出路径 操作系统 操作系统位数,electron,版本,
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 课件教案


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!