{"id":13971,"date":"2023-12-28T18:33:08","date_gmt":"2023-12-28T10:33:08","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=13971"},"modified":"2023-12-28T18:33:08","modified_gmt":"2023-12-28T10:33:08","slug":"%e6%89%8b%e6%9c%ba%e7%bd%91%e7%ab%99%e5%a6%82%e4%bd%95%e7%94%9f%e6%88%90app%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/13971\/","title":{"rendered":"\u624b\u673a\u7f51\u7ad9\u5982\u4f55\u751f\u6210app\uff1f"},"content":{"rendered":"

\u5982\u4f55\u5c06\u624b\u673a\u7f51\u7ad9\u751f\u6210\u4e3aAPP\uff08\u8be6\u7ec6\u6559\u7a0b\uff09<\/p>\n

\u5c06\u624b\u673a\u7f51\u7ad9\u751f\u6210\u4e3aAPP\uff0c\u5b9e\u9645\u4e0a\u662f\u521b\u5efa\u4e00\u4e2a\u539f\u751fApp\uff08\u901a\u5e38\u7528\u4e8eAndroid\u548ciOS\u7cfb\u7edf\uff09\uff0c\u5e76\u5728\u5176\u5185\u90e8\u5d4c\u5165\u4e00\u4e2aWebView\uff0c\u7528\u4e8e\u52a0\u8f7d\u7f51\u7ad9\u5185\u5bb9\u3002\u8fd9\u79cd\u65b9\u6cd5\u79f0\u4e3a\u6df7\u5408App\u5f00\u53d1\u3002\u5728\u8fd9\u4e2a\u8be6\u7ec6\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u5c06\u624b\u673a\u7f51\u7ad9\u751f\u6210\u4e3aAPP\u3002<\/p>\n

\u539f\u7406\uff1a<\/p>\n

\u6df7\u5408App\u5f00\u53d1\u6865\u63a5\u4e86\u539f\u751fApp\u4e0e\u7f51\u7ad9\u4e4b\u95f4\u7684\u5dee\u5f02\u3002\u5b9e\u8d28\u4e0a\uff0c\u6df7\u5408App\u5f00\u53d1\u662f\u5728\u539f\u751fApp\u4e2d\u5d4c\u5165\u4e86\u4e00\u4e2aWebView\uff0c\u901a\u8fc7\u6b64WebView\u6765\u5c55\u793a\u7f51\u7ad9\u5185\u5bb9\u3002\u800c\u539f\u751f\u7279\u6027\u53ef\u4ee5\u901a\u8fc7JS\u6865\u63a5\u6280\u672f\u8c03\u7528\uff0c \u8fd9\u4f7f\u5f97App\u80fd\u591f\u8f7b\u677e\u4f7f\u7528\u539f\u751f\u529f\u80fd\uff0c\u5982\u6444\u50cf\u5934\u3001\u901a\u77e5\u7b49\u3002<\/p>\n

\u6b65\u9aa4\uff1a<\/p>\n

1. \u9009\u62e9\u4e00\u4e2a\u6df7\u5408App\u5f00\u53d1\u6846\u67b6<\/p>\n

\u6709\u5f88\u591a\u6df7\u5408App\u5f00\u53d1\u6846\u67b6\u53ef\u4f9b\u9009\u62e9\uff0c\u5982Cordova\uff08Phonegap\uff09\u3001Ionic\u3001Flutter\u7b49\u3002\u8fd9\u4e9b\u6846\u67b6\u90fd\u4e3a\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u4e86\u5f00\u53d1\u548c\u6253\u5305APP\u7684\u5de5\u5177\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528Cordova\uff0c\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u4e14\u6613\u4e8e\u4e0a\u624b\u7684\u6846\u67b6\u3002<\/p>\n

2. \u5b89\u88c5\u5fc5\u8981\u7684\u5f00\u53d1\u5de5\u5177<\/p>\n

\u4e3a\u4e86\u4f7f\u7528Cordova\uff0c\u9700\u8981\u5b89\u88c5\u4ee5\u4e0b\u5de5\u5177\uff1a<\/p>\n

– Node.js: \u7528\u4e8e\u8fd0\u884cCordova\u547d\u4ee4\u3002<\/p>\n

– Java Development Kit\uff08JDK\uff09: \u82e5\u8981\u521b\u5efaAndroid APP\uff0c\u5219\u9700\u8981JDK\u3002<\/p>\n

– Gradle: \u7528\u4e8e\u6784\u5efaAndroid APP\u3002<\/p>\n

– Android Studio: \u7528\u4e8eAndroid APP\u5f00\u53d1\u3002<\/p>\n

– Xcode: \u82e5\u8981\u5f00\u53d1iOS APP\uff08\u4ec5\u9650Mac OS\u7cfb\u7edf\uff09\u3002<\/p>\n

3. \u5b89\u88c5Cordova<\/p>\n

\u6253\u5f00\u7ec8\u7aef\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u7f51\u9875\u8f6capp\u751f\u6210\u5668<\/a>\u4ee4\uff1a<\/p>\n

“`<\/p>\n

npm install -g cordova<\/p>\n

“`<\/p>\n

4. \u521b\u5efaCordova\u9879\u76ee<\/p>\n

“`<\/p>\n

cordova create myApp com.example.myapp MyApp<\/p>\n

cd myApp<\/p>\n

“`<\/p>\n

5. \u6dfb\u52a0\u76ee\u6807\u5e73\u53f0<\/p>\n

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

\u8fd9\u91cc\u4ee5Android\u5e73\u53f0\u4e3a\u4f8b\uff1a<\/p>\n

“`<\/p>\n

cordova platform add android<\/p>\n

“`<\/p>\n

6. \u5c06\u624b\u673a\u7f51\u7ad9\u5185\u5bb9\u6dfb\u52a0\u5230APP\u4e2d<\/p>\n

\u5c06\u60a8\u7684\u624b\u673a\u7f51\u7ad9\u624b\u673a\u7f51\u7ad9\u6253\u5305\u751f\u6210app<\/a>\u5185\u5bb9\u590d\u5236\u5230Cordova\u9879\u76ee\u4e2d\u201cwww\u201d\u6587\u4ef6\u5939\u3002\u5982\u679c\u60a8\u7684\u624b\u673a\u7f51\u7ad9\u662f\u54cd\u5e94\u5f0f\u7684\uff0c\u5b83\u5c06\u81ea\u52a8\u9002\u5e94\u4e0d\u540c\u8bbe\u5907\u5c4f\u5e55\u5c3a\u5bf8\u3002<\/p>\n

7. \u6dfb\u52a0\u914d\u7f6e\u4fe1\u606f<\/p>\n

\u5728Cordova\u9879\u76ee\u7684\u201cconfig.xml\u201d\u6587\u4ef6\u4e2d\uff0c\u53ef\u4ee5\u914d\u7f6eAPP\u7684\u4fe1\u606f\uff0c\u5982\u540d\u79f0\u3001\u7248\u672c\u53f7\u3001\u6743\u9650\u7b49\u3002<\/p>\n

8. \u5199\u4e00\u6bb5\u7b80\u5355\u7684JS\u4ee3\u7801\u5b9e\u73b0\u6865\u63a5<\/p>\n

\u5728\u201cwww\u201d\u6587\u4ef6\u5939\u4e2d\uff0c\u627e\u5230\u201cindex.js\u201d\uff0c\u5728\u201cdeviceready\u201d\u4e8b\u4ef6\u76d1\u542c\u5668\u91cc\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n

“`<\/p>\n

document.addEventListener(‘deviceready’, function() {<\/p>\n

var webView = new cordova.InAppBrowser.open(‘https:\/\/yourwebsite.com’, ‘_self’,’location=no’);<\/p>\n

}, false);<\/p>\n

“`<\/p>\n

\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u5728APP\u542f\u52a8\u65f6\u6253\u5f00\u6307\u5b9a\u7684\u7f51\u5740\uff0c\u5e76\u9690\u85cf\u5730\u5740\u680f\u3002<\/p>\n

9. \u6784\u5efaAPP<\/p>\n

“`<\/p>\n

cordova build android<\/p>\n

“`<\/p>\n

10. \u5728\u6a21\u62df\u5668\u6216\u771f\u673a\u4e0a\u8fd0\u884cAPP<\/p>\n

“`<\/p>\n

cordova run android<\/p>\n

“`<\/p>\n

\u73b0\u5728\uff0c\u60a8\u5df2\u7ecf\u5c06\u60a8\u7684\u624b\u673a\u7f51\u7ad9\u8f6c\u6362\u6210\u4e86\u4e00\u4e2aAndroid APP\u3002\u7c7b\u4f3c\u5730\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u6b65\u9aa4\u4e3aiOS\u5e73\u53f0\u521b\u5efaAPP\u3002<\/p>\n

\u8fd9\u53ea\u662f\u4e00\u4e2a\u5165\u95e8\u7ea7\u7684\u6559\u7a0b\uff0c\u5b9e\u9645\u9879\u76ee\u53ef\u80fd\u9700\u8981\u5904\u7406\u66f4\u591a\u7ec6\u8282\u3002\u4f46\u968f\u7740\u6df7\u5408App\u5f00\u53d1\u6280\u672f\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u5c06\u624b\u673a\u7f51\u7ad9\u8f6c\u6362\u4e3aAPP\u53d8\u5f97\u8d8a\u6765\u8d8a\u5bb9\u6613\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5982\u4f55\u5c06\u624b\u673a\u7f51\u7ad9\u751f\u6210\u4e3aAPP\uff08\u8be6\u7ec6\u6559\u7a0b\uff09\u5c06\u624b\u673a\u7f51\u7ad9\u751f\u6210\u4e3aAPP\uff0c\u5b9e\u9645\u4e0a\u662f\u521b\u5efa\u4e00\u4e2a\u539f\u751fApp\uff08\u901a\u5e38\u7528\u4e8eAndroid\u548ciOS\u7cfb\u7edf\uff09\uff0c\u5e76\u5728\u5176\u5185\u90e8\u5d4c\u5165\u4e00\u4e2aWebView\uff0c\u7528\u4e8e\u52a0\u8f7d\u7f51\u7ad9\u5185\u5bb9\u3002\u8fd9\u79cd\u65b9\u6cd5\u79f0\u4e3a\u6df7\u5408A<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[18448,6129,384,10444,23],"topic":[],"class_list":{"0":"post-13971","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-appkf","7":"tag-app","8":"tag-6129","9":"tag-384","11":"tag-23"},"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/13971","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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=13971"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/13971\/revisions"}],"predecessor-version":[{"id":14014,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/13971\/revisions\/14014"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=13971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=13971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=13971"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=13971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}