{"id":5486,"date":"2023-09-22T18:37:14","date_gmt":"2023-09-22T10:37:14","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=5486"},"modified":"2023-09-22T18:37:14","modified_gmt":"2023-09-22T10:37:14","slug":"%e5%89%8d%e7%ab%af%e5%bc%80%e5%8f%91h5%e6%80%8e%e4%b9%88%e7%94%9f%e6%88%90app","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/5486\/","title":{"rendered":"\u524d\u7aef\u5f00\u53d1h5\u600e\u4e48\u751f\u6210app?"},"content":{"rendered":"

\u524d\u7aef\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u5c06H5\u7f51\u9875\u5e94\u7528\u8f6c\u6362\u6210App\u6765\u5b9e\u73b0\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u7684\u539f\u751f\u4f53\u9a8c\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0cH5\u5e94\u7528\u5c06\u6253\u5305\u6210\u4e00\u4e2a\u539f\u751f\u5e94\u7528\uff0c\u5e76\u4e14\u80fd\u591f\u8bbf\u95ee\u8bbe\u5907\u7684\u539f\u751f\u529f\u80fd\uff0c\u4f8b\u5982\u76f8\u673a\u3001\u901a\u8baf\u5f55\u7b49\u3002\u63a5\u4e0b\u6765\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecdH5\u5982\u4f55\u751f\u6210App\uff08\u5373\u6df7\u5408\u79fb\u52a8\u5e94\u7528\uff09\u7684\u539f\u7406\u548c\u6b65\u9aa4\u3002<\/p>\n

1. \u539f\u7406<\/p>\n

\u5c06H5\u5e94\u7528\u8f6c\u6362\u4e3aApp\u7684\u6838\u5fc3\u6280\u672f\u5305\u62ec\u6df7\u5408\u5e94\u7528\u6846\u67b6\uff08\u5982Cordova\u3001PhoneGap\u3001Ionic\u7b49\uff09\u548cWebView\u7ec4\u4ef6\u3002\u6df7\u5408\u5e94\u7528\u6846\u67b6\u63d0\u4f9b\u4e86\u5c06H5\u5e94\u7528\u5c01\u88c5\u5230\u539f\u751fApp\u7684\u5de5\u5177\uff0c\u4ee5\u53ca\u5c06JavaScript\u8c03\u7528\u6620\u5c04\u5230\u539f\u751fAPI\u7684\u63d2\u4ef6\u3002WebView\u7ec4\u4ef6\u5219\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5728\u539f\u751f\u5e94\u7528\u4e2d\u5d4c\u5165H5\u9875\u9762\u7684\u5bb9\u5668\u3002\u4f8b\u5982\uff0c\u5373\u4f7f\u662f\u4e00\u4e2a\u5305\u542b\u4e86\u5f88\u591aH5\u5185\u5bb9\u7684App\uff0c\u7528\u6237\u4ecd\u7136\u53ef\u4ee5\u901a\u8fc7\u5e73\u53f0\u539f\u751f\u7684\u8bbe\u5907\u7279\u6027\uff08\u5982\u786c\u4ef6\u52a0\u901f\u3001\u591a\u70b9\u89e6\u63a7\u7b49\uff09\u8fdb\u884c\u4e0e\u5e94\u7528\u7684\u4ea4\u4e92\u3002<\/p>\n

2. \u6b65\u9aa4<\/p>\n

\u4ee5\u4e0b\u662f\u5c06H5\u8f6c\u6362\u4e3aApp\u7684\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/p>\n

\u6b65\u9aa41\uff1a\u9009\u62e9\u4e00\u4e2a\u6df7\u5408\u5e94\u7528\u6846\u67b6<\/p>\n

\u9996\u5148\uff0c\u4f60\u9700\u8981\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u4f60\u9879\u76ee\u9700\u6c42\u548c\u6280\u672f\u8981\u6c42\u7684\u6df7\u5408\u5e94\u7528\u6846\u67b6\u3002\u4e3b\u8981\u7684\u6846\u67b6\u6709\uff1a<\/p>\n

– Cordova<\/p>\n

– PhoneGap\uff08\u57fa\u4e8eCordova\uff09<\/p>\n

– Ionic<\/p>\n

– React Native\uff08\u90e8\u5206\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u5c06H5\u5e94\u7528\u5d4c\u5165\u5230React Native\uff09<\/p>\n

\u6b64\u5904\uff0c\u6211\u4eec\u4ee5Cordova\u4e3a\u4f8b\u8fdb\u884c\u8be6\u89e3\u3002<\/p>\n

\u6b65\u9aa42\uff1a\u5b89\u88c5\u73af\u5883\u548c\u5de5\u5177<\/p>\n

\u5728\u5f00\u59cb\u4f7f\u7528Cordova\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u5df2\u5b89\u88c5\u4ee5\u4e0b\u8f6f\u4ef6\u7f51\u7ad9\u6253\u5305\u751f\u6210app<\/a>\uff1a<\/p>\n

– Node.js (\u5b89\u88c5\u65f6\u6700\u597d\u9009\u62e9LTS\u7248)<\/p>\n

– Gi<\/p>\n

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

t<\/p>\n

– Java Development Kit (JDK) \uff08\u7528\u4e8e\u7f16\u8bd1Android\u5e94\u7528\uff09<\/p>\n

– Android Studio\uff08\u7528\u4e8e\u7f16\u8bd1\u548c\u8fd0\u884cAndroid\u5e94\u7528\uff09<\/p>\n

– Xcode\uff08\u7528\u4e8e\u7f16\u8bd1\u548c\u8fd0\u884ciOS\u5e94\u7528\uff0c\u4ec5\u9002\u7528\u4e8emacOS\uff09<\/p>\n

\u5b89\u88c5\u597d\u57fa\u672c\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528npm\u5b89\u88c5Cordova:<\/p>\n

“`<\/p>\n

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

“`<\/p>\n

\u6b65\u9aa43\uff1a\u521b\u5efaCordova\u9879\u76ee<\/p>\n

\u5728\u5728\u7ebfapp\u5feb\u901f\u751f\u6210\u5e73\u53f0<\/a>\u4f60\u7684\u5de5\u4f5c\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2aCordova\u9879\u76ee\uff1a<\/p>\n

“`<\/p>\n

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

“`<\/p>\n

\u6b64\u547d\u4ee4\u5c06\u5728myApp\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u5305\u542b\u4e86\u57fa\u672c\u7684Cordova\u9879\u76ee\u7ed3\u6784\u3002\u63a5\u7740\u8fdb\u5165\u8be5\u76ee\u5f55\uff1a<\/p>\n

“`<\/p>\n

cd myApp<\/p>\n

“`<\/p>\n

\u6b65\u9aa44\uff1a\u5bfc\u5165H5\u5e94\u7528<\/p>\n

\u5c06\u4f60\u7684H5\u5e94\u7528\u6587\u4ef6\uff08HTML\u3001CSS\u3001JavaScript\u7b49\uff09\u62f7\u8d1d\u5230Cordova\u9879\u76ee\u7684`www`\u76ee\u5f55\u4e2d\u3002\u786e\u4fdd\u4f60\u7684H5\u5e94\u7528\u6709\u4e00\u4e2a\u540d\u4e3a`index.html`\u7684\u4e3b\u9875\u9762\uff0c\u56e0\u4e3aCordova\u9ed8\u8ba4\u4f7f\u7528\u8fd9\u4e2a\u540d\u79f0\u3002<\/p>\n

\u6b65\u9aa45\uff1a\u6dfb\u52a0\u76ee\u6807\u5e73\u53f0<\/p>\n

\u4f7f\u7528\u547d\u4ee4\u4e3aCordova\u9879\u76ee\u6dfb\u52a0\u76ee\u6807\u5e73\u53f0\u3002\u4f8b\u5982\uff0c\u4e3aAndroid\u6dfb\u52a0\u652f\u6301\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

cordova platform add android<\/p>\n

“`<\/p>\n

\u5bf9\u4e8eiOS\u5e73\u53f0\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff08\u9700\u8981\u5728macOS\u73af\u5883\u4e0b\u64cd\u4f5c\uff09\uff1a<\/p>\n

“`<\/p>\n

cordova platform add ios<\/p>\n

“`<\/p>\n

\u6b65\u9aa46\uff1a\u5b89\u88c5\u63d2\u4ef6<\/p>\n

Cordova\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u7528\u4e8e\u8bbf\u95ee\u8bbe\u5907\u539f\u751f\u529f\u80fd\u7684\u63d2\u4ef6\u3002\u6839\u636e\u4f60\u7684\u9700\u6c42\uff0c\u4f7f\u7528\u547d\u4ee4\u5b89\u88c5\u6240\u9700\u7684\u63d2\u4ef6\u3002\u4f8b\u5982\uff0c\u8981\u5b89\u88c5\u76f8\u673a\u63d2\u4ef6\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n

“`<\/p>\n

cordova plugin add cordova-plugin-camera<\/p>\n

“`<\/p>\n

\u6b65\u9aa47\uff1a\u7f16\u8bd1\u548c\u8fd0\u884c<\/p>\n

\u6700\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u7f16\u8bd1\u4f60\u7684App\uff1a<\/p>\n

“`<\/p>\n

cordova build android<\/p>\n

“`<\/p>\n

\u6216\u8005\uff1a<\/p>\n

“`<\/p>\n

cordova build ios<\/p>\n

“`<\/p>\n

\u6210\u529f\u7f16\u8bd1\u540e\uff0c\u4f7f\u7528\u6a21\u62df\u5668\u6216\u8fde\u63a5\u7684\u7269\u7406\u8bbe\u5907\u8fd0\u884c\u4f60\u7684App\uff1a<\/p>\n

“`<\/p>\n

cordova run android<\/p>\n

“`<\/p>\n

\u6216\u8005\uff1a<\/p>\n

“`<\/p>\n

cordova run ios<\/p>\n

“`<\/p>\n

\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9aa4\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u5c06\u4f60\u7684H5\u5e94\u7528\u8f6c\u6362\u4e3a\u539f\u751f\u5e94\u7528\uff0c\u5e76\u5728\u8bbe\u5907\u4e0a\u8fd0\u884c\u3002\u4e0d\u4ec5\u5982\u6b64\uff0c\u4f60\u8fd8\u53ef\u4ee5\u8bbf\u95ee\u539f\u751fAPI\uff0c\u63d0\u4f9b\u66f4\u4e30\u5bcc\u7684\u4ea4\u4e92\u4f53\u9a8c\u3002<\/p>\n

\u603b\u4e4b\uff0c\u5c06H5\u5e94\u7528\u751f\u6210App\u7684\u539f\u7406\u4e3b\u8981\u662f\u901a\u8fc7\u6df7\u5408\u5e94\u7528\u6846\u67b6\u548cWebView\u7ec4\u4ef6\u5b9e\u73b0\u7684\u3002\u6df7\u5408\u5e94\u7528\u6846\u67b6\u8d1f\u8d23\u5c01\u88c5H5\u5e94\u7528\u5e76\u63d0\u4f9b\u8bbf\u95ee\u539f\u751fAPI\u7684\u63d2\u4ef6\uff0c\u800cWebView\u7ec4\u4ef6\u5219\u4f5c\u4e3a\u4e00\u4e2aH5\u5185\u5bb9\u5bb9\u5668\u786e\u4fdd\u548c\u539f\u751f\u8bbe\u5907\u7279\u6027\u7684\u4ea4\u4e92\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u524d\u7aef\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u5c06H5\u7f51\u9875\u5e94\u7528\u8f6c\u6362\u6210App\u6765\u5b9e\u73b0\u5728\u79fb\u52a8\u8bbe\u5907\u4e0a\u7684\u539f\u751f\u4f53\u9a8c\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0cH5\u5e94\u7528\u5c06\u6253\u5305\u6210\u4e00\u4e2a\u539f\u751f\u5e94\u7528\uff0c\u5e76\u4e14\u80fd\u591f\u8bbf\u95ee\u8bbe\u5907\u7684\u539f\u751f\u529f\u80fd\uff0c\u4f8b\u5982\u76f8\u673a\u3001\u901a\u8baf\u5f55\u7b49\u3002\u63a5\u4e0b\u6765\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecdH5\u5982\u4f55\u751f\u6210A<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[10240,832,384,797,10241],"topic":[],"class_list":["post-5486","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-app","tag-832","tag-384","tag-797"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/5486","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\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=5486"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/5486\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=5486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=5486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=5486"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=5486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}