{"id":8846,"date":"2023-11-16T18:34:41","date_gmt":"2023-11-16T10:34:41","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=8846"},"modified":"2023-11-16T18:34:41","modified_gmt":"2023-11-16T10:34:41","slug":"%e5%a6%82%e4%bd%95%e6%8a%8a%e7%bd%91%e9%a1%b5%e7%94%9f%e6%88%90app","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/8846\/","title":{"rendered":"\u5982\u4f55\u628a\u7f51\u9875\u751f\u6210app?"},"content":{"rendered":"

\u5c06\u7f51\u9875\u751f\u6210APP\u7684\u539f\u7406\u4e3b\u8981\u662f\u901a\u8fc7WebView\u6216\u8005Webview\u5bb9\u5668\uff08\u5982PhoneGap\uff09\u5c01\u88c5\u73b0\u6709\u7684\u7f51\u7ad9\u6216Web\u5e94\u7528\uff0c\u4f7f\u5176\u6210\u4e3a\u4e00\u4e2a\u539f\u751fAPP\u5e94\u7528\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u6b65\u9aa4\u548c\u4ecb\u7ecd\uff1a<\/p>\n

1. \u4e86\u89e3WebView\uff1a<\/p>\n

WebView\u662f\u4e00\u79cd\u5728APP\u5e94\u7528\u4e2d\u5d4c\u5165\u7f51\u9875\u7684\u6280\u672f\u3002\u5b83\u5141\u8bb8APP\u4ee5\u539f\u751f\u5e94\u7528\u7684\u5f62\u5f0f\u8fd0\u884c\uff0c\u5e76\u63d0\u4f9b\u4e86\u4e0e\u624b\u673a\u8bbe\u5907\u786c\u4ef6\u548c\u529f\u80fd\u7684\u63a5\u53e3\u3002WebView\u6280\u672f\u5728\u5404\u79cd\u79fb\u52a8\u5e73\u53f0\uff08\u5982Android\u3001iOS\u548cWindows Phone\uff09\u4e2d\u90fd\u6709\u5b9e\u73b0\uff0c\u4f46\u5b9e\u73b0\u65b9\u5f0f\u548cAPI\u53ef\u80fd\u6709\u6240\u4e0d\u540c\u3002<\/p>\n

2. \u642d\u5efa\u5f00\u53d1\u73af\u5883\uff1a<\/p>\n

\u5bf9\u4e8eAndroid\uff0c\u4f60\u9700\u8981\u5b89\u88c5Android Studio\uff1b\u5bf9\u4e8eiOS\uff0c\u4f60\u9700\u8981\u5b89\u88c5Xcode\u3002\u8fd9\u4e9b\u5f00\u53d1\u73af\u5883\u5c06\u4e3a\u4f60\u7684\u5e94\u7528\u63d0\u4f9b\u521b\u5efaAPP\u9879\u76ee\u3001\u7f16\u5199\u4ee3\u7801\u3001\u8c03\u8bd5\u3001\u6d4b\u8bd5\u548c\u53d1\u5e03\u7684\u5de5\u5177\u3002<\/p>\n

3. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684APP\u9879\u76ee\uff1a<\/p>\n

\u5728Android Studio\u6216Xcode\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684APP\u9879\u76ee\uff0c\u5e76\u4e3a\u5176\u9009\u62e9\u4e00\u4e2a\u540d\u79f0\u3001\u5305\u540d\u7b49\u57fa\u672c\u4fe1\u606f\u3002<\/p>\n

4. \u96c6\u6210WebView\uff1a<\/p>\n

\u5728\u9879\u76ee\u7684\u4e3bActivity\uff08Android\uff09\u6216ViewController\uff08iOS\uff09\u4e2d\u5f15\u5165WebView\u7ec4\u4ef6\uff0c\u5e76\u8bbe\u7f6e\u5176\u663e\u793a\u4f60\u7684\u7f51\u9875\u5730\u5740\u3002\u6839\u636e\u9700\u8981\uff0c\u4f60\u4e5f\u53ef\u4ee5\u8c03\u6574WebView\u7684\u884c\u624b\u673a\u7f51\u7ad9app\u751f\u6210<\/a>\u4e3a\uff0c\u4f8b\u5982\uff1a\u7981\u7528\u6eda\u52a8\u3001\u7f29\u653e\u7b49\u3002<\/p>\n

\u4ee3\u7801\u793a\u4f8b\uff08Android\uff09\uff1a<\/p>\n

“`java<\/p>\n

import android.webkit.WebView;<\/p>\n

public class MainActivity extends AppCompatActivity {<\/p>\n

@Override<\/p>\n

protected void onCreate(Bundle savedInstanceState) {<\/p>\n

super.onCreate(savedInstanceState);<\/p>\n

setContentView(R.layout.activity_main);<\/p>\n

WebView webView = (WebView) findViewById(R.id.webview);<\/p>\n

webView.getSettings().setJavaScriptEnabled(true);<\/p>\n

webView.loadUrl(“https:\/\/www.example.com”);<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

\u4ee3\u7801\u793a\u4f8b\uff08iOS\uff09\uff1a<\/p>\n

“`swift<\/p>\n

import UIKit<\/p>\n

im1\u5206\u949f\u7ed9\u4f60\u7684app\u751f\u6210\u4e00\u4e2a\u7f51\u7ad9<\/a>port WebKit<\/p>\n

class ViewController: UIViewContro<\/p>\n

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

ller {<\/p>\n

@IBOutlet weak var webView: WKWebView!<\/p>\n

override func viewDidLoad() {<\/p>\n

super.viewDidLoad()<\/p>\n

let url = URL(string: “https:\/\/www.example.com”)<\/p>\n

let request = URLRequest(url: url!)<\/p>\n

webView.load(request)<\/p>\n

}<\/p>\n

}<\/p>\n

“`<\/p>\n

5. \u6dfb\u52a0APP\u6743\u9650\u548c\u8bbe\u5907\u529f\u80fd\u652f\u6301\uff1a<\/p>\n

\u6839\u636e\u4f60\u7684\u7f51\u9875\u9700\u8981\u4f7f\u7528\u7684\u8bbe\u5907\u529f\u80fd\uff08\u5982\u5b9a\u4f4d\u3001\u6444\u50cf\u5934\u3001\u5b58\u50a8\u7b49\uff09\uff0c\u5728APP\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u5982AndroidManifest.xml\u6216Info.plist\uff09\u4e2d\u7533\u8bf7\u76f8\u5e94\u7684\u6743\u9650\u3002<\/p>\n

6. \u8c03\u8bd5\u3001\u6d4b\u8bd5\u548c\u4f18\u5316\uff1a<\/p>\n

\u4f7f\u7528\u6a21\u62df\u5668\u6216\u5b9e\u4f53\u8bbe\u5907\u8fd0\u884c\u4f60\u7684APP\uff0c\u786e\u4fdd\u5176\u529f\u80fd\u6b63\u5e38\u8fd0\u884c\uff0c\u65e0\u660e\u663e\u7684\u6027\u80fd\u6216\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n

7. \u6253\u5305\u548c\u53d1\u5e03\uff1a<\/p>\n

\u5f53\u4f60\u5bf9APP\u6ee1\u610f\u65f6\uff0c\u53ef\u4ee5\u5c06\u5176\u6253\u5305\u4e3aAPK\uff08Android\uff09\u6216IPA\uff08iOS\uff09\uff0c\u5e76\u5c06\u5176\u53d1\u5e03\u5230\u76f8\u5e94\u7684\u5e94\u7528\u5546\u5e97\u3002<\/p>\n

\u9664\u6b64\u4e4b\u5916\uff0c\u4f60\u8fd8\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u8de8\u5e73\u53f0\u7684Webview\u5bb9\u5668\u6846\u67b6\uff08\u5982PhoneGap\u3001Ionic\u3001React Native\u7b49\uff09\uff0c\u8fd9\u4e9b\u6846\u67b6\u53ef\u4ee5\u8ba9\u4f60\u4f7f\u7528\u4e00\u4efd\u4ee3\u7801\uff0c\u5728\u591a\u4e2a\u5e73\u53f0\u4e0a\u751f\u6210\u539f\u751f\u7684APP\u5e94\u7528\u3002\u8fd9\u53ef\u4ee5\u8282\u7701\u65f6\u95f4\u548c\u7cbe\u529b\uff0c\u4f46\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u989d\u5916\u7684\u5b66\u4e60\u548c\u8c03\u6574\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u5c06\u7f51\u9875\u751f\u6210APP\u7684\u539f\u7406\u4e3b\u8981\u662f\u901a\u8fc7WebView\u6216\u8005Webview\u5bb9\u5668\uff08\u5982PhoneGap\uff09\u5c01\u88c5\u73b0\u6709\u7684\u7f51\u7ad9\u6216Web\u5e94\u7528\uff0c\u4f7f\u5176\u6210\u4e3a\u4e00\u4e2a\u539f\u751fAPP\u5e94\u7528\u3002\u4ee5\u4e0b\u662f\u8be6\u7ec6\u7684\u6b65\u9aa4\u548c\u4ecb\u7ecd\uff1a1. \u4e86\u89e3WebView\uff1a <\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[29,573,15180,149,6119],"topic":[],"class_list":["post-8846","post","type-post","status-publish","format-standard","hentry","category-appkf","tag-29","tag-573","tag-h5app","tag-149","tag-app"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/8846","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\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=8846"}],"version-history":[{"count":0,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/8846\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=8846"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=8846"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=8846"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=8846"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}