\u8f6f\u4ef6\u5305\u5c01\u88c5<\/a>CSS styles *\/<\/p>\n\/* \u4f8b\u5982\uff1a<\/p>\n
body {<\/p>\n
font-family: Arial, sans-serif;<\/p>\n
}<\/p>\n
*\/<\/p>\n
“`<\/p>\n
js\/script.js:<\/p>\n
“`javascript<\/p>\n
\/\/ Add your own JavaScript\u4ee3\u7801<\/p>\n
\/\/ \u4f8b\u5982\uff1a<\/p>\n
function appendNumber(num) {<\/p>\n
document.getElementById(‘display’).value += num;<\/p>\n
}<\/p>\n
“`<\/p>\n
### \u5c06HTML\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aEXE<\/p>\n
\u8981\u5c06HTML\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3aEXE\uff0c\u60a8\u9700\u8981\u505a\u4ee5\u4e0b\u51e0\u6b65\uff1a<\/p>\n
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
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>\n
my-html-app\/<\/p>\n
\u251c\u2500\u2500 package.json<\/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
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
<\/figure>\n<\/p>\nage.json\u6587\u4ef6\u4e2d\uff1a<\/p>\n
“`json<\/p>\n
{<\/p>\n
“name”: “html-calculator”,<\/p>\n
“version”: “1.0.0”,<\/p>\n
“main”: “index.html”,<\/p>\n
“scripts”: {<\/p>\n
“start”: “nw .”<\/p>\n
},<\/p>\n
“window”: {<\/p>\n
“title”: “My HTML Calculator”,<\/p>\n
“width”: 800,<\/p>\n
“height”: 600<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
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>\n
path\/to\/nwjs\/nw .<\/p>\n
“`<\/p>\n
\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
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>\n
npm install -g nw-builder<\/p>\n
“`<\/p>\n
6. \u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u60a8\u7684HTML\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210.exe\u6587\u4ef6\uff1a<\/p>\n
“`<\/p>\n
nwbuild -p win64 my-html-app<\/p>\n
“`<\/p>\n
\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
\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":"
\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}]}}