{"id":16472,"date":"2023-12-27T17:50:12","date_gmt":"2023-12-27T09:50:12","guid":{"rendered":"https:\/\/h5app.yimenapp.cn\/h5app\/?p=16472"},"modified":"2023-12-27T17:50:12","modified_gmt":"2023-12-27T09:50:12","slug":"vue%e6%89%93%e5%8c%85%e6%88%90apk%e6%93%8d%e4%bd%9c%e6%96%b9%e6%b3%95%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/h5app.yimenapp.cn\/h5app\/2023\/sjapp\/16472\/","title":{"rendered":"vue\u6253\u5305\u6210apk\u64cd\u4f5c\u65b9\u6cd5\u4ecb\u7ecd"},"content":{"rendered":"<p>Vue\u662f\u4e00\u4e2a\u6d41\u884c\u7684JavaScript\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u5355\u9875\u5e94\u7528\u7a0b\u5e8f\u3002\u4f46\u662f\uff0c\u5373\u4f7f\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\uff0cVue\u5e94\u7528\u7a0b\u5e8f\u4e5f\u53ef\u4ee5\u50cfWeb\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u8fd0\u884c\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u60f3\u8981\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\uff0c\u4f60\u53ef\u4ee5\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\uff08Android Package Kit\uff09\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u8f6c\u6362\u4e3a\u539f\u751fAndroid\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>APK\u662fAndroid\u5e94\u7528\u7a0b\u5e8f\u7684\u6807\u51c6\u683c\u5f0f\uff0c\u5b83\u5305\u542b\u4e86\u6240\u6709\u5fc5\u9700\u7684\u6587\u4ef6\u548c\u8d44\u6e90\uff0c\u4ee5\u53ca\u5e94\u7528\u7a0b\u5e8f\u7684\u4ee3\u7801\u548c\u903b\u8f91\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u3002<\/p>\n<p>## \u524d\u7f6e\u6761\u4ef6<\/p>\n<p>\u5728\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u4e4b\u524d\uff0c\u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\uff1a<\/p>\n<p>&#8211; Node.js<\/p>\n<p>&#8211; JDK<\/p>\n<p>&#8211; Android SDK<\/p>\n<p>## \u6b65\u9aa4<\/p>\n<p>### 1. \u521b\u5efaVue\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2aVue\u5e94\u7528\u7a0b\u5e8f\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528Vue CLI\u6765\u521b\u5efaVue\u5e94\u7528\u7a0b\u5e8f\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6765\u5b89\u88c5Vue CLI\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm install -g @vue\/cli<\/p>\n<p>&#8220;`<\/p>\n<p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Vue\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>vue create my-app<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmy-app\u201d\u7684\u65b0Vue\u5e94\u7528\u7a0b\u5e8f\u3002\u5728\u521b\u5efa\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u5c06\u88ab\u8981\u6c42\u9009\u62e9\u4e00\u4e9b\u914d\u7f6e\u9009\u9879\uff0c\u4f8b\u5982CSS\u9884\u5904\u7406\u5668\u548c\u57fa\u7840\u914d\u7f6e\u3002\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8Vue\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>cd my-app<\/p>\n<p>npm run serve<\/p>\n<p>&#8220;`<\/p>\n<p>### 2. \u5b89\u88c5Cordova<\/p>\n<p>Cordova\u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u6846\u67b6\uff0c\u7528\u4e8e\u5c06Web\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210\u672c\u5730\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5Cordova\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>npm install -g cordova<\/p>\n<p>&#8220;`<\/p>\n<p>### 3. \u521b\u5efaCordova\u9879\u76ee<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Cordova\u9879\u76ee\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>cordova create my-app com.example.myapp MyApp<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u5728\u5f53\u524d<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-03\/22\/10\/26413490335.jpg\" \/><\/figure>\n<\/p>\n<p>\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<a href=\"https:\/\/appdabao.yimenapp.com\/jiage-2823.html\">gg\u811a\u672c\u6253\u5305\u6210apk<\/a>\u201cmy-app\u201d\u7684\u65b0Cordova\u9879\u76ee<a href=\"https:\/\/appdabao.yimenapp.com\/jiage-1031.html\">\u5b89\u5353app\u5e26\u7f13\u5b58\u6253\u5305<\/a>\u3002\u5176\u4e2d\uff0c\u201ccom.example.myapp\u201d\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u5305\u540d\uff0c\u201cMyApp\u201d\u662f\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u8fdb\u884c\u66f4\u6539\u3002<\/p>\n<p>### 4. \u6dfb\u52a0Android\u5e73\u53f0<\/p>\n<p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06Android\u5e73\u53f0\u6dfb\u52a0\u5230Cordova\u9879\u76ee\u4e2d\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>cd my-app<\/p>\n<p>cordova platform add android<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5fc5\u8981\u7684\u6587\u4ef6\u548c\u4f9d\u8d56\u9879\uff0c\u4ee5\u4fbf\u5728Android\u8bbe\u5907\u4e0a\u8fd0\u884cCordova\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>### 5. \u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u590d\u5236\u5230Cordova\u9879\u76ee\u4e2d<\/p>\n<p>\u73b0\u5728\uff0c\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u590d\u5236\u5230Cordova\u9879\u76ee\u4e2d\u7684\u201cwww\u201d\u76ee\u5f55\u4e2d\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u590d\u5236\u5230Cordova\u9879\u76ee\u4e2d\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>cp -r \/path\/to\/my-app\/dist\/* my-app\/www\/<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u590d\u5236Vue\u5e94\u7528\u7a0b\u5e8f\u7684\u6784\u5efa\u6587\u4ef6\uff08\u901a\u5e38\u5728\u201cdist\u201d\u76ee\u5f55\u4e0b\uff09\u5230Cordova\u9879\u76ee\u7684\u201cwww\u201d\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>### 6. \u7f16\u8f91\u914d\u7f6e\u6587\u4ef6<\/p>\n<p>\u6253\u5f00Cordova\u9879\u76ee\u7684\u201cconfig.xml\u201d\u6587\u4ef6\uff0c\u5e76\u6839\u636e\u9700\u8981\u8fdb\u884c\u4fee\u6539\u3002\u4f60\u53ef\u4ee5\u4fee\u6539\u5e94\u7528\u7a0b\u5e8f\u7684\u540d\u79f0\u3001\u7248\u672c\u53f7\u3001\u56fe\u6807\u7b49\u3002<\/p>\n<p>### 7. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5305\u5e94\u7528\u7a0b\u5e8f\uff1a<\/p>\n<p>&#8220;`<\/p>\n<p>cordova build android<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd9\u5c06\u751f\u6210\u4e00\u4e2aAPK\u6587\u4ef6\uff0c\u4f4d\u4e8eCordova\u9879\u76ee\u7684\u201cplatforms\/android\/app\/build\/outputs\/apk\/debug\/app-debug.apk\u201d\u76ee\u5f55\u4e2d\u3002<\/p>\n<p>### 8. \u5b89\u88c5\u5e94\u7528\u7a0b\u5e8f<\/p>\n<p>\u5c06APK\u6587\u4ef6\u590d\u5236\u5230Android\u8bbe\u5907\u4e0a\uff0c\u5e76\u901a\u8fc7\u6587\u4ef6\u7ba1\u7406\u5668\u5b89\u88c5\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>## \u7ed3\u8bba<\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u4ecb\u7ecd\u4e86\u5982\u4f55\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210APK\u3002\u8fd9\u5c06\u4f7f\u4f60\u7684Vue\u5e94\u7528\u7a0b\u5e8f\u53d8\u6210\u4e00\u4e2a\u539f\u751f\u7684Android\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ece\u800c\u63d0\u4f9b\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Vue\u662f\u4e00\u4e2a\u6d41\u884c\u7684JavaScript\u6846\u67b6\uff0c\u7528\u4e8e\u6784\u5efa\u5355\u9875\u5e94\u7528\u7a0b\u5e8f\u3002\u4f46\u662f\uff0c\u5373\u4f7f\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\uff0cVue\u5e94\u7528\u7a0b\u5e8f\u4e5f\u53ef\u4ee5\u50cfWeb\u5e94\u7528\u7a0b\u5e8f\u4e00\u6837\u8fd0\u884c\u3002\u4f46\u662f\uff0c\u5982\u679c\u4f60\u60f3\u8981\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\uff0c\u4f60\u53ef\u4ee5\u5c06Vue\u5e94\u7528\u7a0b\u5e8f\u6253\u5305\u6210A<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[21722,1001,21723,11,913],"topic":[],"class_list":["post-16472","post","type-post","status-publish","format-standard","hentry","category-sjapp","tag-php","tag-1001","tag-21723","tag-11","tag-913"],"_links":{"self":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/16472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/comments?post=16472"}],"version-history":[{"count":1,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/16472\/revisions"}],"predecessor-version":[{"id":16524,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/posts\/16472\/revisions\/16524"}],"wp:attachment":[{"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/media?parent=16472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/categories?post=16472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/tags?post=16472"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/h5app.yimenapp.cn\/h5app\/wp-json\/wp\/v2\/topic?post=16472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}