{"id":18999,"date":"2024-03-18T15:42:37","date_gmt":"2024-03-18T07:42:37","guid":{"rendered":"https:\/\/www.yimenyun.cn\/emen\/?p=18999"},"modified":"2024-03-18T15:42:37","modified_gmt":"2024-03-18T07:42:37","slug":"win10%e6%a1%8c%e9%9d%a2%e5%ba%94%e7%94%a8html%e5%bc%80%e5%8f%91%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.yimenyun.cn\/emen\/18999\/","title":{"rendered":"win10\u684c\u9762\u5e94\u7528html\u5f00\u53d1\u4ecb\u7ecd"},"content":{"rendered":"

Win10\u684c\u9762\u5e94\u7528HTML\u662f\u4e00\u79cd\u57fa\u4e8eWeb\u6280\u672f\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u65b9\u5f0f\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49Web\u5f00\u53d1\u6280\u672f\u6765\u5f00\u53d1\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdWin10\u684c\u9762\u5e94\u7528HTML\u7684\u539f\u7406\u548c\u5f00\u53d1\u65b9\u5f0f\u3002<\/p>\n

\u4e00\u3001Win10\u684c\u9762\u5e94\u7528HTML\u7684\u539f\u7406<\/p>\n

Win10\u684c\u9762\u5e94\u7528HTML\u662f\u57fa\u4e8eUniversal Windows Platform (UWP)\u7684\u4e00\u79cd\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u65b9\u5f0f\u3002UWP\u662f\u4e00\u79cd\u901a\u7528\u7684\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u5e73\u53f0\uff0c\u5b83\u53ef\u4ee5\u5728\u4e0d\u540c\u7684Windows 10\u8bbe\u5907\u4e0a\u8fd0\u884c\uff0c\u5305\u62ec\u684c\u9762\u7535\u8111\u3001\u5e73\u677f\u7535\u8111\u3001\u624b\u673a\u3001Xbox\u7b49\u3002Win10\u684c\u9762\u5e94\u7528HTML\u662f\u5728UWP\u5e73\u53f0\u4e0a\u57fa\u4e8eWeb\u6280\u672f\u7684\u4e00\u79cd\u5f00\u53d1\u65b9\u5f0f\u3002<\/p>\n

Win10\u684c\u9762\u5e94\u7528HTML\u4f7f\u7528\u4e86WebView\u63a7\u4ef6\u6765\u52a0\u8f7dHTML\u3001CSS\u548cJavaScript\u7b49Web\u9875\u9762\u3002WebView\u662f\u4e00\u79cd\u57fa\u4e8eEdge\u6d4f\u89c8\u5668\u5f15\u64ce\u7684\u63a7\u4ef6\uff0c\u5b83\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u5d4c\u5165Web\u9875\u9762\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u5728WebView\u63a7\u4ef6\u4e2d\u52a0\u8f7dHTML\u3001CSS\u548cJavaScript\u7b49Web\u9875\u9762\uff0c\u5e76\u901a\u8fc7JavaScript\u4e0e\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u4ea4\u4e92\u3002<\/p>\n

\u4e8c\u3001Win10\u684c\u9762\u5e94\u7528HTML\u7684\u5f00\u53d1\u65b9\u5f0f<\/p>\n

Win10\u684c\u9762\u5e94\u7528HTML\u7684\u5f00\u53d1\u65b9\u5f0f\u4e0eWeb\u5f00\u53d1\u975e\u5e38\u76f8\u4f3c\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49Web\u5f00\u53d1\u6280\u672f\u6765\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u3002\u4e0b\u9762\u4ecb\u7ecdWin10\u684c\u9762\u5e94\u7528HTML\u7684\u5f00\u53d1\u6b65\u9aa4\uff1a<\/p>\n

1. \u521b\u5efaUWP\u9879\u76ee<\/p>\n

\u9996\u5148\u9700\u8981\u521b\u5efa\u4e00\u4e2aUWP\u9879\u76ee\uff0c\u53ef\u4ee5\u5728Visual Studio\u4e2d\u9009\u62e9\u201c\u65b0\u5efa\u9879\u76ee\u201d->\u201cVisual C#\u201d->\u201cWindows Universal\u201d->\u201c\u7a7a\u767d\u5e94\u7528\u7a0b\u5e8f\u201d\u6765\u521b\u5efa\u4e00\u4e2a\u7a7a\u767d\u7684UWP\u9879\u76ee\u3002<\/p>\n

2. \u6dfb\u52a0WebView\u63a7\u4ef6<\/p>\n

\u5728XAML\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4e00\u4e2aWebView\u63a7\u4ef6\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

\n

“`<\/p>\n

3. \u52a0\u8f7dWeb\u9875\u9762<\/p>\n

\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528WebView\u63a7\u4ef6\u7684Navigate\u65b9\u6cd5\u6765\u52a0\u8f7dWeb\u9875\u9762\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

webView.Navigate(new Uri(“http:\/\/www.example.com”));<\/p>\n

“`<\/p>\n

4. \u4e0e\u5e94\u7528\u7a0b\u5e8f\u4ea4\u4e92<\/p>\n

\u5728Web\u9875\u9762\u4e2d\u53ef\u4ee5\u901a\u8fc7JavaScript\u4e0e\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u4ea4\u4e92\uff0c\u53ef\u4ee5\u4f7f\u7528WebView\u63a7\u4ef6\u7684ScriptNotify\u4e8b\u4ef6\u6765\u63a5\u6536JavaScript\u53d1\u9001\u7684\u6d88\u606f\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

webView.ScriptNotify += WebView_ScriptNotify;<\/p>\n

private void WebView_ScriptNotify(object sender, NotifyEventArgs e)<\/p>\n

{<\/p>\n

\/\/ \u5904\u7406JavaScript\u53d1\u9001\u7684\u6d88\u606f<\/p>\n

}<\/p>\n

“`<\/p>\n

\u5728Web\u9875\u9762\u4e2d\u53ef\u4ee5\u901a\u8fc7window.external.notify\u65b9\u6cd5\u6765\u53d1\u9001\u6d88\u606f\u7ed9\u5e94\u7528\u7a0b\u5e8f\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

window.external.notify(‘message’);<\/p>\n

“`<\/p>\n

5. \u6253\u5305\u5e94\u7528\u7a0b\u5e8f<\/p>\n

\u5728Visual Studio\u4e2d\u53ef\u4ee5\u4f7f\u7528\u201c\u751f\u6210\u201d->\u201c\u751f\u6210web\u8f6cexe<\/a>\u89e3\u51b3\u65b9\u6848\u201d\u6765\u751f\u6210\u5e94\u7528\u7a0b\u5e8f\uff0c\u751f\u6210\u7684\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5728Windows 10\u8bbe\u5907\u4e0a\u8fd0\u884c\u3002<\/p>\n

\u4e09\u3001\u603b\u7ed3<\/p>\n

Win10\u684c\u9762\u5e94\u7528HTML\u662f\u4e00\u79cd\u57fa\u4e8eWeb\u6280\u672f\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u65b9\u5f0f\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49Web\u5f00\u53d1\u6280\u672f\u6765\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u3002Win1<\/p>\n

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

0\u684c\u9762\u5e94\u7528HTML\u4f7f\u7528\u4e86WebView\u63a7\u4ef6\u6765\u52a0\u8f7dWeb\u9875\u9762\uff0c\u5e76\u901a\u8fc7JavaScript\u4e0e\u5e94\u7528\u7a0b\u5e8f\u8fdb\u884c\u4ea4\u4e92\u3002\u5f00\u53d1\u8005\u53ef\u4ee5\u4f7f\u7528V\u7f51\u7ad9\u600e\u4e48\u6253\u5305\u6210dmg<\/a>isual Studio\u6765\u521b\u5efaUWP\u9879\u76ee\uff0c\u5e76\u5728\u9879\u76ee\u4e2d\u4f7f\u7528WebView\u63a7\u4ef6\u6765\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

Win10\u684c\u9762\u5e94\u7528HTML\u662f\u4e00\u79cd\u57fa\u4e8eWeb\u6280\u672f\u7684\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u65b9\u5f0f\uff0c\u5b83\u5141\u8bb8\u5f00\u53d1\u8005\u4f7f\u7528HTML\u3001CSS\u548cJavaScript\u7b49Web\u5f00\u53d1\u6280\u672f\u6765\u5f00\u53d1\u684c\u9762\u5e94\u7528\u7a0b\u5e8f\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecdWin10\u684c\u9762\u5e94\u7528HTM<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[21591,12,989,3048,21592],"topic":[],"class_list":["post-18999","post","type-post","status-publish","format-standard","hentry","category-exekf","tag-exe","tag-12","tag-989","tag-3048"],"_links":{"self":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18999","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\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/comments?post=18999"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18999\/revisions"}],"predecessor-version":[{"id":19036,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/posts\/18999\/revisions\/19036"}],"wp:attachment":[{"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/media?parent=18999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/categories?post=18999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/tags?post=18999"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.yimenyun.cn\/emen\/wp-json\/wp\/v2\/topic?post=18999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}