{"id":10292,"date":"2022-02-04T16:40:50","date_gmt":"2022-02-04T08:40:50","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10292"},"modified":"2022-02-04T16:40:50","modified_gmt":"2022-02-04T08:40:50","slug":"html-inputmode-keyboard","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2022\/02\/html-inputmode-keyboard\/","title":{"rendered":"HTML inputmode\u4e0eiOS Android\u8f6f\u952e\u76d8\u7c7b\u578b\u6d4b\u8bd5"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10292\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10292<\/a> \u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202202-inputmode.png';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202202\/inputmode-cover.png\" width=\"480\" height=\"313\" alt=\"\u6570\u5b57\u952e\u76d8\u622a\u56fe\" class=\"alignright clip thumb size-medium\" \/><\/p>\n<h3>\u4e00\u3001\u9700\u6c42\u80cc\u666f<\/h3>\n<p>\u6709\u4e00\u4e2a\u9a8c\u8bc1\u7801\u8f93\u5165\u6846\uff0c\u7531\u4e8e\u9a8c\u8bc1\u7801\u53ea\u80fd\u8f93\u5165\u6570\u503c\uff0c\u56e0\u6b64\uff0c\u5e0c\u671b\u5728\u624b\u673a\u4e0a\u547c\u8d77\u7684\u8f6f\u952e\u76d8\u662f\u6570\u5b57\u952e\u76d8\u3002<\/p>\n<p>number \u7c7b\u578b\u548c tel \u7c7b\u578b\u7684\u8f93\u5165\u6846\u662f\u53ef\u4ee5\u547c\u8d77\u6570\u5b57\u952e\u76d8\u7684\uff0c\u4f46\u662f\u5728\u8fd9\u4e2a\u573a\u666f\u4e0b\uff0c\u8bed\u4e49\u662f\u4e0d\u7b26\u5408\u7684\uff0c\u4f1a\u5f71\u54cd\u8f85\u52a9\u8bbe\u5907\u7684\u8bc6\u522b\u3002<\/p>\n<pre>&lt;!-- \u53ef\u4ee5\u547c\u8d77\u6570\u5b57\u8f6f\u952e\u76d8 --&gt;\r\n&lt;input type=\"number\"&gt;\r\n&lt;input type=\"tel\"&gt;<\/pre>\n<p>\u800c <code>&lt;input&gt;<\/code> \u8f93\u5165\u6846\u5e76\u6ca1\u6709\u4e13\u95e8\u7684\u9a8c\u8bc1\u7801\u8bed\u4e49\u7c7b\u578b\uff0c\u90a3\u6709\u6ca1\u6709\u4ec0\u4e48\u529e\u6cd5\u8ba9\u666e\u901a\u8f93\u5165\u6846\u4e5f\u80fd\u547c\u8d77\u6570\u5b57\u952e\u76d8\u5462\uff1f<\/p>\n<p>\u5bfb\u5bfb\u89c5\u89c5\u4e2d\uff0c\u53d1\u73b0\u4e86\u4e00\u4e2a HTML \u5c5e\u6027 <code>inputmode<\/code>\uff0c\u53ef\u4ee5\u5728\u4e0d\u6539\u53d8\u8f93\u5165\u6846 <code>type<\/code> \u7c7b\u578b\u7684\u60c5\u51b5\u4e0b\u6307\u5b9a\u8f93\u5165\u7684\u6a21\u5f0f\uff0c\u5176\u517c\u5bb9\u6027\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202202\/2022-02-04_145248.png\" width=\"641\" height=\"381\" alt=\"inputmode \u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u8fd8\u662f\u633a\u4e0d\u9519\u7684\uff0c\u8d76\u5feb\u770b\u770b\u5728\u79fb\u52a8\u7aef\u4e0b\u7684\u6548\u679c\u5982\u4f55\uff0c\u6b63\u597d\uff0c\u6211 Android \u548c iOS \u624b\u673a\u90fd\u6709\uff0c\u6d4b\u6d4b\u770b\u3002<\/p>\n<h3>\u4e8c\u3001inputmode\u5c5e\u6027\u5b9e\u8df5<\/h3>\n<p><code>inputmode<\/code> \u652f\u6301\u4e0b\u9762\u8fd9\u4e9b\u5c5e\u6027\u503c\uff1a<\/p>\n<dl>\n<dt><strong>none<\/strong><\/dt>\n<dd>\u4e0d\u4f7f\u7528\u865a\u62df\u952e\u76d8\uff0c\u8fd9\u4e2a\u65f6\u5019\u9875\u9762\u9700\u8981\u4f7f\u7528\u81ea\u5b9a\u4e49\u7684\u952e\u76d8\u4ee3\u66ff<\/dd>\n<dt><strong>text<\/strong><\/dt>\n<dd>\u9ed8\u8ba4\u503c\uff0c\u4f1a\u663e\u793a\u6807\u51c6\u8f93\u5165\u952e\u76d8<\/dd>\n<dt><strong>decimal<\/strong><\/dt>\n<dd>\u5c0f\u6570\u8868\u793a\u952e\u76d8\uff0c\u9664\u4e86\u6570\u5b57\u4e4b\u5916\u53ef\u80fd\u4f1a\u6709\u5c0f\u6570\u70b9 <code>.<\/code> \u6216\u8005\u5343\u5206\u7b26\u9017\u53f7 <code>,<\/code>\u3002<\/dd>\n<dt><strong>numeric<\/strong><\/dt>\n<dd>\u663e\u793a0-9\u7684\u6570\u5b57\u952e\u76d8\u3002<\/dd>\n<dt><strong>tel<\/strong><\/dt>\n<dd>\u624b\u673a\u6570\u5b57\u952e\u76d8\uff0c\u4f1a\u6709\u661f\u53f7 <code>*<\/code> \u6216\u8005\u4e95\u53f7 <code>#<\/code> \u952e\u3002<\/dd>\n<dt><strong>search<\/strong><\/dt>\n<dd>\u63d0\u4ea4\u6309\u94ae\u4f1a\u663e\u793a <code>'search'<\/code> \u6216\u8005 &#8216;\u641c\u7d22&#8217;\u3002<\/dd>\n<dt><strong>email<\/strong><\/dt>\n<dd>\u952e\u76d8\u4e0a\u4f1a\u6709 <code>@<\/code> \u7b26\u53f7\u952e\u3002<\/dd>\n<dt><strong>url<\/strong><\/dt>\n<dd>\u952e\u76d8\u4e0a\u4f1a\u6709\u659c\u6760 <code>\/<\/code> \u7b26\u53f7\u952e\u3002<\/dd>\n<\/dl>\n<p>\u5728\u672c\u4f8b\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u7684\u6d4b\u8bd5\u7684\u952e\u76d8\u8f93\u5165\u7c7b\u578b\u662f <code>inputmode=\"numeric\"<\/code>\uff0c\u6d4b\u8bd5\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>\u9a8c\u8bc1\u7801\uff1a&lt;input inputmode=\"numeric\"&gt;<\/pre>\n<p><small class=\"hidden\">\/\/zxx: \u5982\u679c\u4f60\u770b\u5230\u8fd9\u6bb5\u6587\u5b57\uff0c\u8bf4\u660e\u4f60\u73b0\u5728\u8bbf\u95ee\u662f\u4e0d\u662f\u539f\u6587\u7ad9\u70b9\uff0c\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u5728\u8fd9\u91cc\uff1ahttps:\/\/www.zhangxinxu.com\/wordpress\/?p=10292\uff08\u4f5c\u8005\u5f20\u946b\u65ed\uff09<\/small><\/p>\n<h4>\u6d4b\u8bd5\u7ed3\u679c<\/h4>\n<p>\u6574\u4e86\u4e2a\u6d4b\u8bd5\u9875\u9762\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202202\/html-inputmode-demo.php\" rel=\"noopener\" target=\"_blank\">HTML inputmode\u5c5e\u6027\u6d4b\u8bd5demo<\/a><\/p>\n<p>\u7ed3\u679c\u5728\u6211\u7684 Android \uff08\u8363\u8000\uff09 \u548c iOS \uff08\u82f9\u679c\uff09\u624b\u673a\u4e2d\u90fd\u663e\u793a\u4e86\u6570\u5b57\u952e\u76d8\uff0c\u5f88\u8d5e\uff01<\/p>\n<p>\u622a\u5c4f\u56fe\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202202\/inputmode-cut1.png\" width=\"240\" height=\"533\" alt=\"\u6570\u5b57\u952e\u76d8\u622a\u56fe Android\" class=\"alignnone size-medium\" \/> <img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202202\/inputmode-cut2.png\" width=\"240\" height=\"427\" alt=\"\u6570\u5b57\u952e\u76d8 iOS \u7cfb\u7edf\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u7136\u540e\u987a\u4fbf\u6d4b\u8bd5\u4e86\u4e0b\u5176\u4ed6\u7684\u8f93\u5165\u7c7b\u578b\uff0c<code>none<\/code> \u5c5e\u6027\u3001<code>tel<\/code> \u5c5e\u6027\u8fd8\u6709 <code>decimal<\/code> \u5c5e\u6027\u503c\u90fd\u652f\u6301\u826f\u597d\uff0c\u4ee5\u53ca\uff1a<\/p>\n<ul>\n<li>\u4e24\u4e2a\u7cfb\u7edf\u4e0b\uff0c<code>decimal<\/code> \u548c <code>numeric<\/code> \u952e\u76d8\u90fd\u662f\u4e00\u6837\u7684\u3002<\/li>\n<li><code>email<\/code> \u7c7b\u578b\u652f\u6301\u4e0d\u660e\u663e\uff0c\u65e0\u8bba\u54ea\u4e2a\u7cfb\u7edf\u4e0b\u3002<\/li>\n<li><code>url<\/code> \u7c7b\u578b Android \u4e0b\u652f\u6301\u597d\u4e00\u70b9\uff0c<code>search<\/code> \u7c7b\u578b\u5728 iOS \u4e0b\u652f\u6301\u597d\u4e00\u70b9\u3002<\/li>\n<\/ul>\n<p>\u4e0d\u8fc7\u6211\u7684\u624b\u673a\u5e76\u4e0d\u80fd\u4ee3\u8868\u6240\u6709\u7684\u624b\u673a\uff0c\u4ee5\u4e0a\u6d4b\u8bd5\u7ed3\u679c\u4ec5\u4f9b\u53c2\u8003\u3002<\/p>\n<h3>\u4e09\u3001\u6700\u7ec8\u7684\u7ed3\u8bba<\/h3>\n<p>\u5982\u679c\u662f\u9a8c\u8bc1\u7801\u8f93\u5165\u6846\uff0c\u8bf7\u52a1\u5fc5\u4f7f\u7528\u4e0b\u9762\u7684 HTML \u4ee3\u7801\u5b9e\u73b0\uff1a<\/p>\n<pre>&lt;input inputmode=\"numeric\"&gt;<\/pre>\n<p>\u8fd9\u6837\uff0c\u7528\u6237\u547c\u8d77\u952e\u76d8\u53ef\u4ee5\u76f4\u63a5\u6309\u4e0b\u6570\u5b57\uff0c\u7528\u6237\u4f53\u9a8c\u5c31\u4f1a\u66f4\u597d\u3002<\/p>\n<p>\u81f3\u4e8e\u5176\u4ed6\u7684\uff0c\u4ec0\u4e48 email, tel, url \u4e4b\u6d41\uff0c\u8fd8\u662f\u4f7f\u7528\u5bf9\u5e94\u7684\u539f\u751f\u7684\u8f93\u5165\u6846\u5b9e\u73b0\uff0c\u57fa\u672c\u4e0a\u4e0d\u5b58\u5728\u9700\u8981\u4f7f\u7528 <code>inputmode<\/code> \u5c5e\u6027\u5b9e\u73b0\u7684\u573a\u666f\uff1a<\/p>\n<pre>&lt;input type=\"email\"&gt;\r\n&lt;input type=\"tel\"&gt;\r\n&lt;input type=\"url\"&gt;\r\n&lt;input type=\"search\"&gt;<\/pre>\n<p>\u597d\uff0c\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u7684\u5168\u90e8\u5185\u5bb9\uff0c\u4e00\u4e2a\u6e90\u81ea\u5b9e\u9645\u5f00\u53d1\u9700\u6c42\u7684\u5b9e\u73b0\u63a2\u7d22\uff0c\u6700\u540e\u5f97\u5230\u4e86\u4ee4\u4eba\u6b23\u559c\u7684\u7ed3\u679c\uff0c\u8fd8\u662f\u5f88\u4e0d\u9519\u7684\u3002<\/p>\n<p>\u4eca\u5929\u6b63\u6708\u521d\u56db\uff0c\u6b63\u662f\u8fce\u8d22\u795e\u7684\u65f6\u5019\uff0c\u795d\u5927\u5bb6\u4eca\u5e74\u90fd\u53d1\u5927\u8d22\uff0c\u8f6c\u53d1\u672c\u6587<button onclick=\"shareWeixin.click()\" class=\"entry-share-btn\">\u5206\u4eab<\/button>\u8d22\u795e\uff0c\u8d22\u6e90\u6eda\u6eda\u6765\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202202\/rich.jpg\" width=\"86\" height=\"147\" alt=\"\u8d22\u795e\u7237\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=10292\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=10292<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202202\/inputmode-cover.png\" width=\"160\" height=\"104\" alt=\"\u6570\u5b57\u952e\u76d8\u622a\u56fe\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u9a8c\u8bc1\u7801\u8f93\u5165\u6846\u4f7f\u7528 inputmode \u5c5e\u6027\u662f\u6bcb\u5eb8\u7f6e\u7591\u7684\u6700\u4f73\u5b9e\u8df5\uff0c\u539f\u56e0\u548c\u5206\u6790\u89c1\u672c\u6587\u5177\u4f53\u5185\u5bb9\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1097],"tags":[9,37,1553,1125],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10292"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=10292"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/10292\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=10292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=10292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=10292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}