{"id":1307,"date":"2023-03-18T11:13:27","date_gmt":"2023-03-18T03:13:27","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1307"},"modified":"2023-04-29T09:15:29","modified_gmt":"2023-04-29T01:15:29","slug":"when-ios-12-soft-keyboard-on-wechat-h5-page-is-retracted-the-page-does-not-rebound-causing-the-cursor-position-to-be-disordered-and-unable-to-focus-when-clicking-on-the-input-box-area-again","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/18\/when-ios-12-soft-keyboard-on-wechat-h5-page-is-retracted-the-page-does-not-rebound-causing-the-cursor-position-to-be-disordered-and-unable-to-focus-when-clicking-on-the-input-box-area-again\/","title":{"rendered":"\u5fae\u4fe1H5\u9875\u9762 ios12 \u8f6f\u952e\u76d8\u6536\u56de\u65f6\u9875\u9762\u4e0d\u56de\u5f39\uff0c\u5bfc\u81f4\u5149\u6807\u4f4d\u7f6e\u9519\u4e71\uff0c\u518d\u6b21\u70b9\u51fb\u8f93\u5165\u6846\u533a\u57df\u65f6\u65e0\u6cd5focus"},"content":{"rendered":"<p>\u95ee\u9898\u63cf\u8ff0\uff1aios12+\uff0c\u5fae\u4fe1H5\u9875\u9762\u5b58\u5728bug\uff0c\u952e\u76d8\u6536\u56de\u65f6\uff0c\u754c\u9762\u6ca1\u6709\u6062\u590d\uff0c\u5e95\u4e0b\u51fa\u73b0\u7a7a\u767d\u533a\u57df\uff0c\u5e76\u5bfc\u81f4\u5149\u6807\u4f4d\u7f6e\u9519\u4e71\uff0c\u518d\u6b21\u70b9\u51fb\u8f93\u5165\u6846\u533a\u57df\u65f6\u65e0\u6cd5focus\uff0c\u5f39\u6846\u6309\u94ae\u65e0\u6cd5\u70b9\u51fb<\/p>\n<p>\u89e3\u51b3\u65b9\u6848\uff1a\u5f53input\u5931\u7126\uff0c\u952e\u76d8\u6536\u56de\u540e\uff0c\u6eda\u52a8\u4e00\u4e0b\u9875\u9762\u5c31\u53ef\u4ee5\u4f7f\u9875\u9762\u6062\u590d\u6b63\u5e38<\/p>\n<p><!-- more --><\/p>\n<p>\u8865\u5145\uff1a\u5f53\u5728\u624b\u673a\u53f7\u4e0e\u9a8c\u8bc1\u7801\u4e4b\u95f4\u5207\u6362\u8f93\u5165\u65f6\uff0c\u4f1a\u540c\u65f6\u89e6\u53d1\u524d\u8f93\u5165\u6846\u7684blur\u548c\u540e\u8f93\u5165\u6846focus\uff0c\u8fd9\u4e2a\u65f6\u5019\u89e6\u53d1\u6eda\u52a8\uff0c\u9875\u9762\u4f1a\u51fa\u73b0\u8f83\u5927\u8df3\u8dc3\uff0c\u56e0\u6b64\u901a\u8fc7inFocus \u548c setTimeout \u5224\u65ad\uff0c\u662f\u5207\u6362input\u8fd8\u662f\u771f\u6b63blur\uff0c\u771f\u6b63blur\u7684\u65f6\u5019\uff0c\u518d\u6eda\u52a8\u9875\u9762<\/p>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/developers.weixin.qq.com\/community\/develop\/doc\/00044ae90742f8c82fb78fcae56800\">https:\/\/developers.weixin.qq.com\/community\/develop\/doc\/00044ae90742f8c82fb78fcae56800<\/a><br \/>\n\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/blog.csdn.net\/qq_23370345\/article\/details\/84757505\">https:\/\/blog.csdn.net\/qq_23370345\/article\/details\/84757505<\/a><br \/>\n\u53c2\u8003\uff1a<a target=\"_blank\" rel=\"noopener\" href=\"https:\/\/blog.csdn.net\/u010200636\/article\/details\/85004087\">https:\/\/blog.csdn.net\/u010200636\/article\/details\/85004087<\/a><\/p>\n<pre><code class=\"language-javascript\">methods: {\n  getBlur(input) {\n    var _this = this\n    setTimeout(function () {\n      \/\/ \u5f53input \u5931\u7126\u65f6\uff0c\u6eda\u52a8\u4e00\u4e0b\u9875\u9762\u5c31\u53ef\u4ee5\u4f7f\u9875\u9762\u6062\u590d\u6b63\u5e38\n      _this.checkWxScroll();\n    }, 200)\n  },\n  checkWxScroll() {\n    \/\/if (isIphone()) {\n      this.temporaryRepair();\n    \/\/}\n    \/\/var ua = navigator.userAgent.toLowerCase();\n    \/\/var u = navigator.userAgent.match(\/\\(i[^;]+;( U;)? CPU.+Mac OS X\/);\n\n    \/\/if (ua.match(\/MicroMessenger\/i) == &#039;micromessenger&#039; &amp;&amp; !!u) { \/\/\u5728iphone \u5fae\u4fe1\u4e2d\n\/\/      var osVersion = navigator.userAgent.match(\/iPhone\\sOS\\s([\\d\\_]+)\/i);\n\/\/      var osArr = osVersion.length &gt;= 1 ? osVersion[1].split(&#039;_&#039;) : [];\n\/\/      var newOS = osArr.length&gt;=2 &amp;&amp; (versionArr[0]&gt;11)\n\/\/      if (newOS) { \/\/\u5982\u679ciphone\u7248\u672c\u53f7&gt;=12\n        \/\/this.temporaryRepair();\n\/\/      }\n    \/\/}\n  },\n  temporaryRepair() {\n    var currentPosition, timer;\n    var speed = 1; \/\/\u9875\u9762\u6eda\u52a8\u8ddd\u79bb\n    timer = setInterval(function() {\n      currentPosition = document.documentElement.scrollTop || document.body.scrollTop;\n      currentPosition -= speed;\n      window.scrollTo(0, 0); \/\/\u9875\u9762\u5411\u4e0a\u6eda\u52a8\n\/\/    currentPosition += speed; \/\/speed\u53d8\u91cf\n\/\/    window.scrollTo(0, currentPosition); \/\/\u9875\u9762\u5411\u4e0b\u6eda\u52a8\n      clearInterval(timer);\n    }, 1);\n  },\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u63cf\u8ff0\uff1aios12+\uff0c\u5fae\u4fe1H5\u9875\u9762\u5b58\u5728bug\uff0c\u952e\u76d8\u6536\u56de\u65f6\uff0c\u754c\u9762\u6ca1\u6709\u6062\u590d\uff0c\u5e95\u4e0b\u51fa\u73b0\u7a7a\u767d\u533a\u57df\uff0c\u5e76\u5bfc\u81f4\u5149\u6807\u4f4d\u7f6e\u9519\u4e71 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[159,308],"class_list":["post-1307","post","type-post","status-publish","format-standard","hentry","category-frontend-basic","tag-h5","tag-308"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1307"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1307\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}