{"id":1835,"date":"2023-06-27T12:19:21","date_gmt":"2023-06-27T04:19:21","guid":{"rendered":"https:\/\/www.zhidianwl.com\/zhidian\/2023\/1835\/"},"modified":"2023-06-27T12:19:21","modified_gmt":"2023-06-27T04:19:21","slug":"html-%e7%94%9f%e6%88%90-exe%e5%b8%b8%e7%94%a8%e5%b7%a5%e5%85%b7%e6%8e%a8%e8%8d%90","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.com\/zhidian\/2023\/1835\/","title":{"rendered":"html \u751f\u6210 exe\u5e38\u7528\u5de5\u5177\u63a8\u8350"},"content":{"rendered":"

python\u751f\u6210 exe<\/a> <\/p>\n

\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u5982\u4f55\u5c06HTML\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff08.exe\uff09\u3002\u8fd9\u53ef\u4ee5\u4f7f\u60a8\u7684web\u5e94\u7528\u7a0b\u5e8f\u8f7b\u677e\u5730\u5728\u4e0d\u9700\u8981\u6d4f\u89c8\u5668\u6216\u5b89\u88c5\u5176\u4ed6\u8f6f\u4ef6\u7684\u60c5\u51b5\u4e0b\uff0c\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5de5\u4f5c\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u6807\uff0c\u6211\u4eec\u5c06\u4f7f\u7528\u4e00\u4e2a\u540d\u4e3aNW.js\uff08\u539f\u540dNode-Webkit\uff09\u7684\u6846\u67b6\u3002<\/p>\n

### NW.js\uff08Node-Webkit\uff09\u7b80\u4ecb<\/p>\n

NW.js\u662f\u4e00\u4e2a\u53ef\u4ee5\u8ba9\u60a8\u4f7f\u7528HTML\u3001CSS\u3001JavaScript\u548cNode.js\u5f00\u53d1\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u7684\u5f00\u6e90\u6846\u67b6\u3002\u901a\u8fc7NW.js\uff0c\u60a8\u53ef\u4ee5\u5c06\u60a8\u7684Web\u5e94\u7528\u7a0b\u5e8f\u5305\u88c5\u6210\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684\u53ef\u6267\u884c\u7a0b\u5e8f\uff0c\u53ef\u5728Windows\u3001macOS\u548cLinux\u4e0a\u8fd0\u884c\u3002<\/p>\n

### \u5f00\u53d1HTML\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u9996\u5148\uff0c\u6211\u4eec\u5c06\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684HTML\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u60a8\u9009\u62e9\u7684\u76ee\u5f55\u4e2d\u521b\u5efa\u4ee5\u4e0b\u6587\u4ef6\u548c\u6587\u4ef6\u5939\uff1a<\/p>\n

“`<\/p>\n

my-html-app\/<\/p>\n

\u251c\u2500\u2500 index.html<\/p>\n

\u251c\u2500\u2500 css\/<\/p>\n

\u2502 \u2514\u2500\u2500 style.css<\/p>\n

\u2514\u2500\u2500 js\/<\/p>\n

\u2514\u2500\u2500 script.js<\/p>\n

“`<\/p>\n

\u5b8c\u6210\u8fd9\u4e2a\u6b65\u9aa4\u540e\uff0c\u6211\u4eec\u5c06\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684HTML\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f8b\u5982\u4e00\u4e2a\u8ba1\u7b97\u5668\u3002\u8bf7\u5728\u76f8\u5e94\u7684\u6587\u4ef6\u4e2d\u7f16\u5199\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n

index.html:<\/p>\n

“`html<\/p>\n<\/p>\n

\n

\n

HTML Calculator<\/title><\/p>\n<\/p>\n<p>\n<p>\n<p>\n<p> <!-- Add your buttons here --><\/p>\n<p> <!–\u4f8b\u5982\uff1a<button>1<\/button>–><\/p>\n<\/p>\n<\/p>\n<\/p>\n<p>“`<\/p>\n<p>css\/style.css:<\/p>\n<p>“`css<\/p>\n<p>\/* Add your own <a href=\"https:\/\/www.yimenexe.com\/exe-kaifa-3172.html\">\u8f6f\u4ef6\u5305\u5c01\u88c5<\/a>CSS styles *\/<\/p>\n<p>\/* \u4f8b\u5982\uff1a<\/p>\n<p>body {<\/p>\n<p> font-family: Arial, sans-serif;<\/p>\n<p>}<\/p>\n<p>*\/<\/p>\n<p>“`<\/p>\n<p>js\/script.js:<\/p>\n<p>“`javascript<\/p>\n<p>\/\/ Add your own JavaScript\u4ee3\u7801<\/p>\n<p>\/\/ \u4f8b\u5982\uff1a<\/p>\n<p>function appendNumber(num) {<\/p>\n<p> document.getElementById(‘display’).value += num;<\/p>\n<p>}<\/p>\n<p>“`<\/p>\n<p>### \u5c06HTML\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aEXE<\/p>\n<p>\u8981\u5c06HTML\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aEXE\uff0c\u60a8\u9700\u8981\u505a\u4ee5\u4e0b\u51e0\u6b65\uff1a<\/p>\n<p>1. \u4e0b\u8f7d\u5e76\u5b89\u88c5NW.js: \u8bbf\u95eeNW.js\u7684\u5b98\u65b9\u7f51\u7ad9\uff08https:\/\/nwjs.io\/\uff09\uff0c\u4e0b\u8f7d\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u6700\u65b0\u7248\u672c\u5e76\u89e3\u538b\u3002<\/p>\n<p>2. \u4fee\u6539my-html-app\u76ee\u5f55\u7ed3\u6784\uff0c\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3a\u201cpackage.json\u201d\u7684\u6587\u4ef6\uff1a<\/p>\n<p> “`<\/p>\n<p> my-html-app\/<\/p>\n<p> \u251c\u2500\u2500 package.json<\/p>\n<p> \u251c\u2500\u2500 index.html<\/p>\n<p> \u251c\u2500\u2500 css\/<\/p>\n<p> \u2502 \u2514\u2500\u2500 style.css<\/p>\n<p> \u2514\u2500\u2500 js\/<\/p>\n<p> \u2514\u2500\u2500 script.js<\/p>\n<p> “`<\/p>\n<p>3. \u521b\u5efapackage.json\u6587\u4ef6\u4ee5\u5b9a\u4e49\u5e94\u7528\u7a0b\u5e8f\u7684\u5143\u6570\u636e\u3002\u5c06\u4ee5\u4e0b\u5185\u5bb9\u6dfb\u52a0\u5230pack<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/21\/10\/02714928547.jpg\" \/><\/figure>\n<\/p>\n<p>age.json\u6587\u4ef6\u4e2d\uff1a<\/p>\n<p> “`json<\/p>\n<p> {<\/p>\n<p> “name”: “html-calculator”,<\/p>\n<p> “version”: “1.0.0”,<\/p>\n<p> “main”: “index.html”,<\/p>\n<p> “scripts”: {<\/p>\n<p> “start”: “nw .”<\/p>\n<p> },<\/p>\n<p> “window”: {<\/p>\n<p> “title”: “My HTML Calculator”,<\/p>\n<p> “width”: 800,<\/p>\n<p> “height”: 600<\/p>\n<p> }<\/p>\n<p> }<\/p>\n<p> “`<\/p>\n<p>4. \u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u6216\u7ec8\u7aef\uff0c\u8f6c\u5230my-html-app\u76ee\u5f55\uff0c\u5e76\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u4ee5\u6d4b\u8bd5\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p> “`<\/p>\n<p> path\/to\/nwjs\/nw .<\/p>\n<p> “`<\/p>\n<p> \u8bf7\u5c06`path\/to\/nwjs`\u66ff\u6362\u4e3a\u60a8\u89e3\u538bNW.js\u6846\u67b6\u7684\u5b9e\u9645\u8def\u5f84\u3002\u5982\u679c\u4e00\u5207\u987a\u5229\uff0c\u60a8\u7684HTML\u8ba1\u7b97\u5668\u5e94\u7528\u7a0b\u5e8f\u5e94\u8be5\u5728\u4e00\u4e2a\u65b0\u7a97\u53e3\u4e2d\u6253\u5f00\u3002<\/p>\n<p>5. \u4e3a\u4e86\u5c06\u5176\u6253\u5305\u4e3aexe\u6587\u4ef6\uff0c\u53ef\u4ee5\u4f7f\u7528\u50cf`nw-builder`\u4e4b\u7c7b\u7684\u5de5\u5177\u3002\u9996\u5148\uff0c\u901a\u8fc7npm\u5168\u5c40\u5b89\u88c5`nw-builder`\uff1a<\/p>\n<p> “`<\/p>\n<p> npm install -g nw-builder<\/p>\n<p> “`<\/p>\n<p>6. \u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u60a8\u7684HTML\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210.exe\u6587\u4ef6\uff1a<\/p>\n<p> “`<\/p>\n<p> nwbuild -p win64 my-html-app<\/p>\n<p> “`<\/p>\n<p> \u8fd9\u5c06\u5728my-html-app\u76ee\u5f55\u4e2d\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u201cbuild\u201d\u6587\u4ef6\u5939\uff0c\u5176\u4e2d\u5305\u542b\u53ef\u6267\u884c\u6587\u4ef6\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u751f\u6210\u7684\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u5c06\u4e3a\u201cnw.exe\u201d\u3002\u53ef\u4ee5\u901a\u8fc7\u5728`package.json`\u4e2d\u6dfb\u52a0`”displayName”`\u5c5e\u6027\u6765\u81ea\u5b9a\u4e49\u5e94\u7528\u7a0b\u5e8f\u540d\u79f0\u3002<\/p>\n<p>\u795d\u8d3a\u60a8\u6210\u529f\u5730\u5c06HTML\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u4e86\u72ec\u7acb\u7684EXE\u6587\u4ef6\uff01\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u5728\u6ca1\u6709\u5b89\u88c5\u4efb\u4f55\u6d4f\u89c8\u5668\u6216\u5176\u4ed6\u8f6f\u4ef6\u7684Windows\u8ba1\u7b97\u673a\u4e0a\u8fd0\u884c\u6b64\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u8ba8\u8bba\u5982\u4f55\u5c06HTML\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u72ec\u7acb\u7684\u53ef\u6267\u884c\u6587\u4ef6\uff08.exe\uff09\u3002\u8fd9\u53ef\u4ee5\u4f7f\u60a8\u7684web\u5e94\u7528\u7a0b\u5e8f\u8f7b\u677e\u5730\u5728\u4e0d\u9700\u8981\u6d4f\u89c8\u5668\u6216\u5b89\u88c5\u5176\u4ed6\u8f6f\u4ef6\u7684\u60c5\u51b5\u4e0b\uff0c\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5de5\u4f5c\u3002\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e2a\u76ee\u6807<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[3902,14,186,3903,171],"class_list":["post-1835","post","type-post","status-publish","format-standard","hentry","category-zuoexe","tag-vueexeexe","tag-14","tag-186","tag-windows","tag-171"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/1835","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=1835"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/1835\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=1835"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=1835"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=1835"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}