{"id":7289,"date":"2023-10-20T15:32:04","date_gmt":"2023-10-20T07:32:04","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=7289"},"modified":"2023-10-20T15:32:04","modified_gmt":"2023-10-20T07:32:04","slug":"%e7%94%a8vue%e6%89%93%e5%8c%85%e7%9a%84app%e7%94%b5%e8%84%91%e5%8f%af%e6%89%a7%e8%a1%8cexe%e6%80%8e%e4%b9%88%e5%81%9a%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/7289\/","title":{"rendered":"\u7528vue\u6253\u5305\u7684app\u7535\u8111\u53ef\u6267\u884cexe\u600e\u4e48\u505a\uff1f"},"content":{"rendered":"

\u6807\u9898\uff1a\u4f7f\u7528 Vue.js \u6784\u5efa\u5e76\u6253\u5305\u684c\u9762\u5e94\u7528\u7684\u8be6\u7ec6\u6559\u7a0b<\/p>\n

\u6458\u8981\uff1a\u672c\u6559\u7a0b\u4e3b\u8981\u4ecb\u7ecd\u4e86\u4f7f\u7528 Vue.js \u6846\u67b6\u6765\u6784\u5efa\u684c\u9762\u5e94\u7528\u7684\u6280\u5de7\uff0c\u5e76\u8be6\u8ff0\u5982\u4f55\u5bf9\u5176\u8fdb\u884c\u7f16\u8bd1\u548c\u6253\u5305\uff0c\u4ee5\u4fbf\u5728\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u5e73\u53f0\u4e0a\u6267\u884c\u3002<\/p>\n

\u4e00\u3001\u80cc\u666f\u4ecb\u7ecd<\/p>\n

Vue.js \u662f\u4e00\u4e2a\u7528\u4e8e\u6784\u5efa\u7528\u6237\u754c\u9762\u7684\u6e10\u8fdb\u5f0f\u6846\u67b6\u3002Vue<\/p>\n

<\/figure>\n<\/p>\n

.js \u7684\u6838\u5fc3\u5e93\u53ea\u5173\u6ce8\u89c6\u56fe\u5c42\uff0c\u6613\u4e8e\u4e0e\u5176\u4ed6\u5e93\u6216\u5df2\u6709\u9879\u76ee\u6574\u5408\u3002\u4f46\u662f\u5728\u67d0\u4e9b\u573a\u666f\u4e0b\uff0c\u6211\u4eec\u5e0c\u671b\u5c06 Vue.js \u6784\u5efa\u7684\u9875\u9762\u4f5c\u4e3a\u684c\u9762\u5e94\u7528\u6765\u8fd0\u884c\uff0c\u90a3\u4e48\u6211\u4eec\u8be5\u600e\u4e48\u505a\u5462\uff1f\u7b54\u6848\u662f\uff1a\u7ed3\u5408 Electron\u3002<\/p>\n

Electron \u662f\u4e00\u4e2a\u80fd\u5c06 JavaScript, HTML, CSS \u7b49 Web \u6280\u672f\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8de8\u5e73\u53f0\u684c\u9762\u5e94\u7528\u5f00\u53d1\u6846\u67b6\u3002\u56e0\u6b64\uff0c\u7ed3\u5408 Vue.js \u548c Electron \u53ef\u4ee5\u5b9e\u73b0\u6240\u9700\u76ee\u6807\u3002<\/p>\n

\u672c\u6559\u7a0b\u5c06\u4f1a\u6307\u5bfc\u4f60\u5b8c\u6210\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u4f7f\u7528 Vue.js \u7f16\u5199\u4e00\u4e2a\u7b80\u6613\u5e94\u7528\uff0c\u4e4b\u540e\u901a\u8fc7\u96c6\u6210 Electron \u6253\u5305\u6210\u684c\u9762\u5e94\u7528\u3002<\/p>\n

\u4e8c\u3001\u6784\u5efa Vue.js \u5e94\u7528<\/p>\n

1. \u5b89\u88c5 Node.js \u548c npm\uff1a\u9996\u5148\u9700\u8981\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86 Node.js \u548c npm\u3002\u53ef\u4ee5\u5728 Node.js \u5b98\u7f51\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002<\/p>\n

2. \u5b89\u88c5 Vue CLI\uff1aVue CLI \u662f\u4e00\u4e2a\u57fa\u4e8e Vue.js \u8fdb\u884c\u5feb\u901f\u5f00\u53d1\u7684\u5b8c\u6574\u7cfb\u7edf\u3002\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 npm \u5b89\u88c5 Vue CLI\uff1a<\/p>\n

“`<\/p>\n

npm install -g @vue\/cli<\/p>\n

“`<\/p>\n

3. \u521b\u5efa Vue \u9879\u76ee\uff1a\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Vue \u9879\u76ee\uff1a<\/p>\n

“`<\/p>\n

vue create my-project<\/p>\n

“`<\/p>\n

4. \u8fd0\u884c Vue \u9879\u76ee\uff1a\u8fdb\u5165\u9879\u76ee\u76ee\u5f55\u5e76\u8fd0\u884c\u9879\u76ee\uff1a<\/p>\n

“`<\/p>\n

cd my-project<\/p>\n

npm run serve<\/p>\n

“`<\/p>\n

\u73b0\u5728\u4f60\u7684 Vue \u9879\u76ee\u5df2\u7ecf\u521b\u5efa\u5e76app\u5185\u5d4ch5<\/a>\u8fd0\u884c\uff0c\u63a5\u4e0b\u6765\u6211\u4eec\u5c06\u4e3a\u5176\u96c6\u6210 Electron\u3002<\/p>\n

\u4e09\u3001\u96c6\u6210 Electron<\/p>\n

1. \u5b89\u88c5 Vue CLI \u63d2\u4ef6 Electron Builder\uff1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5 Vue CLI \u63d2\u4ef6 Electron Builder\uff1a<\/p>\n

“`<\/p>\n

vue add electron-builder<\/p>\n

“`<\/p>\n

2. \u9879\u76ee\u7ed3\u6784\u8c03\u6574\uff1a\u5728 src \u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a \u201cbackground.js\u201d\u7684\u6587\u4ef6\uff0c\u8fd9\u4e2a\u6587\u4ef6\u5c06\u4f5c\u4e3a Electron \u5e94\u7528\u7684\u4e3b\u8fdb\u7a0b\u3002\u7136\u540e\uff0c\u5c06 package.json \u4e2d\u7684 “main” \u548c “electron” \u5b57\u6bb5\u5206\u522b\u4fee\u6539\u4e3a “src\/background.js” \u548c “electron”\u3002\u8fd9\u6837 Electron \u5c31\u77e5\u9053\u4ece “src\/background.js” \u6587\u4ef6\u5f00\u59cb\u8fd0\u884c\u3002<\/p>\n

3. \u8fd0\u884c Electron \u5e94\u7528\uff1a\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u901a\u8fc7 Electron \u542f\u52a8 Vue \u5e94\u7528\uff1a<\/p>\n

“`<\/p>\n

npm run electron:serve<\/p>\n

“`<\/p>\n

\u73b0\u5728\u4f60\u5df2\u7ecf\u6210\u529f\u96c6\u6210 Electron \u5e76\u8fd0\u884c\u8d77\u6765\u4e86\uff0c\u63a5\u4e0b\u6765\u5c06\u8bf4\u660e\u5982\u4f55\u6253\u5305\u8be5\u5e94\u7528\u4e3a\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

\u56db\u3001\u6253\u5305\u5e94\u7528<\/p>\n

1. \u8bbe\u7f6e\u5efa\u8bae\uff1a\u5728”package.json”\u6587\u4ef6\u4e2d\u6dfb\u52a0 “build” \u5bf9\u8c61\uff0c\u4ee5\u65b9\u4fbf\u5bf9\u6253\u5305\u505a\u51fa\u4e00\u4e9b\u81ea\u5b9a\u4e49\u8bbe\u7f6e\uff0c\u4f8b\u5982\u5e94\u7528\u540d\u79f0\u3001\u56fe\u6807\u7b49\u3002<\/p>\n

2. \u6253\u5305\u547d\u4ee4\uff1a\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

npm run electron:build<\/p>\n

“`<\/p>\n

3. \u8f93\u51fa\u6587\u4ef6\uff1a\u7ecf\u8fc7\u4e00\u7cfb\u5217\u6784\u5efa\u548c\u6253\u5305\u8fc7\u7a0b\u540e\uff0c\u8f93\u51fa\u6587\u4ef6\u4f1a\u88ab\u4fdd\u5b58\u5728 “dist_electron” \u6587\u4ef6\u5939\u4e2d\u3002\u4f60\u53ef\u4ee5\u5728\u6b64\u627e\u5230\u9488\u5bf9\u4e0d\u540c\u5e73\u53f0\uff08\u5982 Windows\u3001macOS \u7b49\uff09\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n

\u81f3\u6b64\uff0c\u4e00\u4e2a\u4f7f\u7528 Vue.js \u642d\u5efa\u5e76\u901a\u8fc7 Electron \u6253\u5305\u7684\u684c\u9762\u5e94\u7528\u5c31\u8bde\u751f\u4e86\uff01\u4f60\u53ef\u4ee5\u5b66\u4e60\u66f4\u591a\u5173\u4e8e Vue.js \u548c Electh5\u5f00\u53d1app<\/a>ron \u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u7f16\u5199\u66f4\u4e3a\u590d\u6742\u7684\u684c\u9762\u5e94\u7528\u6765\u6ee1\u8db3\u5b9e\u9645\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6807\u9898\uff1a\u4f7f\u7528 Vue.js \u6784\u5efa\u5e76\u6253\u5305\u684c\u9762\u5e94\u7528\u7684\u8be6\u7ec6\u6559\u7a0b\u6458\u8981\uff1a\u672c\u6559\u7a0b\u4e3b\u8981\u4ecb\u7ecd\u4e86\u4f7f\u7528 Vue.js \u6846\u67b6\u6765\u6784\u5efa\u684c\u9762\u5e94\u7528\u7684\u6280\u5de7\uff0c\u5e76\u8be6\u8ff0\u5982\u4f55\u5bf9\u5176\u8fdb\u884c\u7f16\u8bd1\u548c\u6253\u5305\uff0c\u4ee5\u4fbf\u5728\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u5e73\u53f0\u4e0a\u6267\u884c\u3002\u4e00\u3001\u80cc\u666f\u4ecb\u7ecdVu<\/p>\n","protected":false},"author":24,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[12986,3865,16,3048,23],"topic":[],"class_list":["post-7289","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-webapp","tag-app","tag-16","tag-3048","tag-23"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/7289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=7289"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/7289\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=7289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=7289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=7289"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=7289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}