当前位置: 首页 > Web前端 > HTML

electronjs入门_2019年2月14日

时间:2023-04-02 20:27:38 HTML

什么是electronjs?可以用javascript编写,windows/mac/linux接口程序的开发框架。参见:https://electronjs.org/https://electronjs.org/docs快速入门先决条件:nodejs安装gitgitclonehttps://github.com/electron/e...cdelectron-quick-startnpminstallnpmstart参考:https://electronjs.org/docs/t...https://electronjs.org/docs/t...项目结构如何发布项目并下载对应的发布包:https://github.com/electron/e...解压到对应目录将项目放入解压后的目录Windows直接双击:electron.exe见https://electronjs.org/docs/t...如何打包项目(最简单的方式)installasarnpminstall-gasar使用asar打包asarpackyour-appapp.asar把app.asar替换成上一步的目录integrateJqueryinstalljquerynpminstall--save-devjqueryindex.html添加兼容代码在html中添加:test1按钮在javascript中添加:$(function(){$("#bnt_test1").click(function(){alert("test1")});});主进程与渲染进程通信渲染进程constipc=require('electron').ipcRendererconstasyncMsgBtn=document.getElementById('async-msg')$("#bnt_test1").click(function(){ipc.send('asynchronous-message','ping')})主进程constipc=require('electron').ipcMainipc.on('asynchronous-message',function(event,arg){event.sender.send('asynchronous-reply','pong')//或开始对话等})见:https://segmentfault.com/a/11...https://segmentfault.com/a/11...