{"id":31184,"date":"2024-11-25T08:34:11","date_gmt":"2024-11-25T00:34:11","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31184\/"},"modified":"2024-11-25T08:34:11","modified_gmt":"2024-11-25T00:34:11","slug":"%e5%be%ae%e4%bf%a1%e7%a6%81%e6%ad%a2%e4%b8%8b%e6%8b%89%e6%9f%a5%e7%9c%8burl%e5%a6%82%e4%bd%95%e5%a4%84%e7%90%86","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31184\/","title":{"rendered":"\u5fae\u4fe1\u7981\u6b62\u4e0b\u62c9\u67e5\u770bURL\u5982\u4f55\u5904\u7406"},"content":{"rendered":"<p>\u5fae\u4fe1\u4e0b\u62c9\u65f6\u53ef\u4ee5\u67e5\u770b\u5230url\uff0c\u672c\u8eab\u662f\u5fae\u4fe1\u7684\u4e00\u79cd\u5b89\u5168\u7b56\u7565\u4e4b\u4e00\uff0c\u4e5f\u662f\u4e00\u79cd\u7528\u6237\u4ea4\u4e92\u53cb\u597d\u7684\u4f53\u9a8c\uff1b\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5fae\u4fe1\u7981\u6b62\u4e0b\u62c9\u67e5\u770burl\u7684\u5904\u7406\u65b9\u6cd5,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\u3002<\/p>\n<p><strong>\u6548\u679c\u539f\u7406\uff1a<\/strong><\/p>\n<p>\u5fae\u4fe1\u4e0b\u62c9\u5f39\u6027\u6548\u679c\u5176\u5b9e\u662f\u6d4f\u89c8\u5668\u672c\u8eab\u7684\u4e00\u79cd\u7279\u6027\uff0c\u91cd\u70b9\u5c31\u662fscroll\u503c\u7684\u4e00\u79cd\u4f53\u73b0\uff1b<\/p>\n<p><strong>\u5904\u7406\u7b56\u7565\uff1a<\/strong><\/p>\n<p>1\u3001\u76f4\u63a5\u7981\u6b62mobile\u7aef\u7684touchmove\u4e8b\u4ef6\uff1b<\/p>\n<p>\u8fd9\u79cd\u7b56\u7565\u4e00\u822c\u9002\u7528\u9875\u9762\u53ea\u6709\u4e00\u5c4f\u4e0d\u9700\u8981\u4e0b\u62c9\u60c5\u51b5\u4e0b\u4f7f\u7528\uff1b<\/p>\n<p><\/p>\n<pre>var&nbsp;touch1&nbsp;=&nbsp;function(){\r\n&nbsp;&nbsp;document.querySelector(\u2018body\u2018).addEventListener(\u2018touchmove\u2018,&nbsp;function&nbsp;(e)&nbsp;{&nbsp;\r\n&nbsp;&nbsp;&nbsp;&nbsp;e.preventDefault();&nbsp;\r\n&nbsp;&nbsp;});\r\n}<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5f0a\u7aef\uff1a\u5bf9\u4e8e\u5927\u5c0f\u4e0d\u540c\u7684\u5c4f\u8981\u8003\u8651\u5230\u5185\u5bb9\u4e00\u5c4f\u5168\u90e8\u663e\u793a\uff0c\u4e0d\u71362+\u5c4f\u7684\u5185\u5bb9\u5c31\u6ca1\u6709\u529e\u6cd5\u770b\u4e86\uff1b<\/p>\n<p>2\u3001\u7981\u6b62touchmove\u540c\u65f6\u5224\u65adscroll\u7684\u4f4d\u7f6e\u662f\u5426\u5230\u8fbe\u9876\u90e8\uff1b<\/p>\n<p>\u8003\u8651\u5230\u4e0b\u62c9\u65f6\u6eda\u52a8\u6761\u662f\u5426\u5230\u8fbe\u9876\u90e8 <\/p>\n<p><\/p>\n<pre>var&nbsp;touch2&nbsp;=&nbsp;function&nbsp;()&nbsp;{\r\n&nbsp;&nbsp;var&nbsp;lastY;\/\/\u6700\u540e\u4e00\u6b21y\u5750\u6807\u70b9\r\n&nbsp;&nbsp;var&nbsp;betterY;\/\/\u6bcf\u6b21touch\u6700\u9ad8\u70b9\r\n&nbsp;&nbsp;document.querySelector(\u2018body\u2018).addEventListener('touchstart',&nbsp;function(event)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;lastY&nbsp;=&nbsp;event.originalEvent.changedTouches[0].clientY;\r\n&nbsp;&nbsp;&nbsp;&nbsp;betterY&nbsp;=&nbsp;lastY;\r\n&nbsp;&nbsp;});\r\n&nbsp;&nbsp;document.querySelector(\u2018body\u2018).addEventListener('touchmove',&nbsp;function(event)&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;y&nbsp;=&nbsp;event.originalEvent.changedTouches[0].clientY;\r\n&nbsp;&nbsp;&nbsp;&nbsp;if(y&nbsp;&amp;gt;&nbsp;betterY){\r\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;betterY&nbsp;=&nbsp;y;\r\n&nbsp;&nbsp;&nbsp;&nbsp;}\r\n&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;st&nbsp;=&nbsp;document.body.scrollTop;&nbsp;\/\/\u6eda\u52a8\u6761\u9ad8\u5ea6\r\n&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(y&nbsp;&amp;gt;=&nbsp;lastY&nbsp;&amp;amp;&amp;amp;&nbsp;st&nbsp;&lt;p&gt;\u5f0a\u7aef\uff1a\u7b2c\u4e00\u6b21\u7684touchmove\u5b58\u5728\u6f0f\u6d1e\u95ee\u9898\uff0ctouchmove\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5b58\u5728\u6f0f\u6d1e&lt;\/p&gt;&lt;p&gt;3\u3001\u76d1\u542cscroll\u7684\u6eda\u52a8\u4e8b\u4ef6\uff0c\u7981\u6b62\u9ad8\u5ea6&lt;\/p&gt;&lt;p&gt;\u6bcf\u5f53\u6eda\u52a8\u6761\u7684\u9ad8\u5ea6\u5c0f\u4e8e0\u65f6\u5c31\u91cd\u7f6e\u4e3a0\uff0c\u5f3a\u5236\u56de\u9000\u9876\u90e8\u4f4d\u7f6e&lt;\/p&gt;&lt;p class=\"jb51code\"&gt;&lt;br&gt;&lt;\/p&gt;&lt;pre class=\"brush:js;\"&gt;var&nbsp;touch3&nbsp;=&nbsp;function&nbsp;()&nbsp;{\r\n&nbsp;&nbsp;window.onscroll&nbsp;=&nbsp;function&nbsp;()&nbsp;{\r\n&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;top&nbsp;=&nbsp;document.documentElement.scrollTop&nbsp;||&nbsp;document.body.scrollTop;\r\n&nbsp;&nbsp;&nbsp;&nbsp;if(top&nbsp;&lt;p&gt;\u5f0a\u7aef\uff1a\u4f1a\u5b58\u5728\u4e0b\u62c9URL\u95ea\u5c4f\u7684\u73b0\u8c61&lt;\/p&gt;&lt;p&gt;\u76f8\u5173\u63a8\u8350\uff1a&lt;br&gt;&lt;\/p&gt;&lt;p&gt;&lt;a href=\"http:\/\/www.php.cn\/js-tutorial-385809.html\" target=\"_self\"&gt;node.js\u4e2dhttp\u6a21\u5757\u548curl\u6a21\u5757\u7b80\u4ecb&lt;\/a&gt;&lt;\/p&gt;&lt;p&gt;&lt;a href=\"http:\/\/www.php.cn\/php-weizijiaocheng-384041.html\" target=\"_self\"&gt;\u8be6\u89e3\u4fee\u6539Laravel\u4e2durl()\u7684\u6839\u5730\u5740&lt;\/a&gt;&lt;\/p&gt;&lt;p&gt;&lt;a href=\"http:\/\/www.php.cn\/php-weizijiaocheng-383129.html\" target=\"_self\"&gt;php\u5982\u4f55\u89e3\u6790url\u4e2d\u7684\u4e2d\u6587\u5b57\u7b26&lt;\/a&gt;&lt;\/p&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u7981\u6b62\u4e0b\u62c9\u67e5\u770bURL\u5982\u4f55\u5904\u7406\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fae\u4fe1\u4e0b\u62c9\u65f6\u53ef\u4ee5\u67e5\u770b\u5230url\uff0c\u672c\u8eab\u662f\u5fae\u4fe1\u7684\u4e00\u79cd\u5b89\u5168\u7b56\u7565\u4e4b\u4e00\uff0c\u4e5f\u662f\u4e00\u79cd\u7528\u6237\u4ea4\u4e92\u53cb\u597d\u7684\u4f53\u9a8c\uff1b\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5fae\u4fe1\u7981\u6b62\u4e0b\u62c9\u67e5\u770burl\u7684\u5904\u7406\u65b9\u6cd5,\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e0b\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\u3002 \u6548\u679c\u539f\u7406\uff1a \u5fae\u4fe1\u4e0b\u62c9\u5f39\u6027\u6548\u679c\u5176\u5b9e\u662f\u6d4f\u89c8\u5668\u672c\u8eab\u7684\u4e00\u79cd\u7279\u6027\uff0c\u91cd\u70b9\u5c31\u662fscroll\u503c\u7684\u4e00\u79cd\u4f53\u73b0\uff1b \u5904\u7406\u7b56\u7565\uff1a 1\u3001\u76f4\u63a5\u7981\u6b62mobile\u7aef\u7684touchmove\u4e8b\u4ef6\uff1b \u8fd9\u79cd\u7b56\u7565\u4e00\u822c\u9002\u7528\u9875\u9762\u53ea\u6709\u4e00\u5c4f\u4e0d\u9700\u8981\u4e0b\u62c9\u60c5\u51b5\u4e0b\u4f7f\u7528\uff1b var&nbsp;touch1&nbsp;=&nbsp;function(){ &nbsp;&nbsp;document.querySelector(\u2018body\u2018).addEventListener(\u2018touchmove\u2018,&nbsp;function&nbsp;(e)&nbsp;{&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;e.preventDefault();&nbsp; &nbsp;&nbsp;}); } \u767b\u5f55\u540e\u590d\u5236 \u5f0a\u7aef\uff1a\u5bf9\u4e8e\u5927\u5c0f\u4e0d\u540c\u7684\u5c4f\u8981\u8003\u8651\u5230\u5185\u5bb9\u4e00\u5c4f\u5168\u90e8\u663e\u793a\uff0c\u4e0d\u71362+\u5c4f\u7684\u5185\u5bb9\u5c31\u6ca1\u6709\u529e\u6cd5\u770b\u4e86\uff1b 2\u3001\u7981\u6b62touchmove\u540c\u65f6\u5224\u65adscroll\u7684\u4f4d\u7f6e\u662f\u5426\u5230\u8fbe\u9876\u90e8\uff1b \u8003\u8651\u5230\u4e0b\u62c9\u65f6\u6eda\u52a8\u6761\u662f\u5426\u5230\u8fbe\u9876\u90e8 var&nbsp;touch2&nbsp;=&nbsp;function&nbsp;()&nbsp;{ &nbsp;&nbsp;var&nbsp;lastY;\/\/\u6700\u540e\u4e00\u6b21y\u5750\u6807\u70b9 &nbsp;&nbsp;var&nbsp;betterY;\/\/\u6bcf\u6b21touch\u6700\u9ad8\u70b9 &nbsp;&nbsp;document.querySelector(\u2018body\u2018).addEventListener(&#8216;touchstart&#8217;,&nbsp;function(event)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;lastY&nbsp;=&nbsp;event.originalEvent.changedTouches[0].clientY; &nbsp;&nbsp;&nbsp;&nbsp;betterY&nbsp;=&nbsp;lastY; &nbsp;&nbsp;}); &nbsp;&nbsp;document.querySelector(\u2018body\u2018).addEventListener(&#8216;touchmove&#8217;,&nbsp;function(event)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;y&nbsp;=&nbsp;event.originalEvent.changedTouches[0].clientY; &nbsp;&nbsp;&nbsp;&nbsp;if(y&nbsp;&amp;gt;&nbsp;betterY){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;betterY&nbsp;=&nbsp;y; &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;st&nbsp;=&nbsp;document.body.scrollTop;&nbsp;\/\/\u6eda\u52a8\u6761\u9ad8\u5ea6 &nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(y&nbsp;&amp;gt;=&nbsp;lastY&nbsp;&amp;amp;&amp;amp;&nbsp;st&nbsp;&lt;p&gt;\u5f0a\u7aef\uff1a\u7b2c\u4e00\u6b21\u7684touchmove\u5b58\u5728\u6f0f\u6d1e\u95ee\u9898\uff0ctouchmove\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5b58\u5728\u6f0f\u6d1e&lt;\/p&gt;&lt;p&gt;3\u3001\u76d1\u542cscroll\u7684\u6eda\u52a8\u4e8b\u4ef6\uff0c\u7981\u6b62\u9ad8\u5ea6&lt;\/p&gt;&lt;p&gt;\u6bcf\u5f53\u6eda\u52a8\u6761\u7684\u9ad8\u5ea6\u5c0f\u4e8e0\u65f6\u5c31\u91cd\u7f6e\u4e3a0\uff0c\u5f3a\u5236\u56de\u9000\u9876\u90e8\u4f4d\u7f6e&lt;\/p&gt;&lt;p class=&#8221;jb51code&#8221;&gt;&lt;br&gt;&lt;\/p&gt;&lt;pre class=&#8221;brush:js;&#8221;&gt;var&nbsp;touch3&nbsp;=&nbsp;function&nbsp;()&nbsp;{ &nbsp;&nbsp;window.onscroll&nbsp;=&nbsp;function&nbsp;()&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;top&nbsp;=&nbsp;document.documentElement.scrollTop&nbsp;||&nbsp;document.body.scrollTop; &nbsp;&nbsp;&nbsp;&nbsp;if(top&nbsp;&lt;p&gt;\u5f0a\u7aef\uff1a\u4f1a\u5b58\u5728\u4e0b\u62c9URL\u95ea\u5c4f\u7684\u73b0\u8c61&lt;\/p&gt;&lt;p&gt;\u76f8\u5173\u63a8\u8350\uff1a&lt;br&gt;&lt;\/p&gt;&lt;p&gt;&lt;a href=&#8221;http:\/\/www.php.cn\/js-tutorial-385809.html&#8221; target=&#8221;_self&#8221;&gt;node.js\u4e2dhttp\u6a21\u5757\u548curl\u6a21\u5757\u7b80\u4ecb&lt;\/a&gt;&lt;\/p&gt;&lt;p&gt;&lt;a href=&#8221;http:\/\/www.php.cn\/php-weizijiaocheng-384041.html&#8221; target=&#8221;_self&#8221;&gt;\u8be6\u89e3\u4fee\u6539Laravel\u4e2durl()\u7684\u6839\u5730\u5740&lt;\/a&gt;&lt;\/p&gt;&lt;p&gt;&lt;a href=&#8221;http:\/\/www.php.cn\/php-weizijiaocheng-383129.html&#8221; target=&#8221;_self&#8221;&gt;php\u5982\u4f55\u89e3\u6790url\u4e2d\u7684\u4e2d\u6587\u5b57\u7b26&lt;\/a&gt;&lt;\/p&gt; \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u7981\u6b62\u4e0b\u62c9\u67e5\u770bURL\u5982\u4f55\u5904\u7406\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-31184","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31184","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=31184"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31184\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31184"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}