{"id":27517,"date":"2024-11-24T10:56:13","date_gmt":"2024-11-24T02:56:13","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27517\/"},"modified":"2024-11-24T10:56:13","modified_gmt":"2024-11-24T02:56:13","slug":"%e5%a6%82%e4%bd%95%e7%94%a8%e9%bc%a0%e6%a0%87%e6%bb%9a%e8%bd%ae%e5%ae%9e%e7%8e%b0%e5%9b%ba%e5%ae%9a%e9%ab%98%e5%ba%a6%e4%b8%80%e9%a1%b5%e6%bb%9a%e5%8a%a8%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27517\/","title":{"rendered":"\u5982\u4f55\u7528\u9f20\u6807\u6eda\u8f6e\u5b9e\u73b0\u56fa\u5b9a\u9ad8\u5ea6\u4e00\u9875\u6eda\u52a8\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173128376073519.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7528\u9f20\u6807\u6eda\u8f6e\u5b9e\u73b0\u56fa\u5b9a\u9ad8\u5ea6\u4e00\u9875\u6eda\u52a8\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7528\u9f20\u6807\u6eda\u8f6e\u5b9e\u73b0\u56fa\u5b9a\u9ad8\u5ea6\u4e00\u9875\u6eda\u52a8\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5b9e\u73b0\u9875\u9762\u9f20\u6807\u6eda\u8f6e\u6eda\u52a8\u56fa\u5b9a\u9ad8\u5ea6\u4e00\u9875\u7684\u6548\u679c\uff1f<\/strong><\/p>\n<p>\u4f60\u9047\u5230\u7684\u8fd9\u4e2a\u95ee\u9898\u662f\u5b9e\u73b0\u4e00\u4e2a\u7c7b\u4f3c\u4e8e\u8f6e\u64ad\u56fe\u7684\u6548\u679c\uff0c\u5f53\u7528\u6237\u9f20\u6807\u6eda\u8f6e\u5411\u4e0b\u6eda\u52a8\u65f6\uff0c\u9875\u9762\u4f1a\u4ee5\u56fa\u5b9a\u9ad8\u5ea6\u5411\u4e0b\u6ed1\u52a8\u4e00\u9875\u3002\u8981\u5b9e\u73b0\u8fd9\u4e00\u6548\u679c\uff0c\u4f60\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p><strong>\u4f7f\u7528 swiper.js \u5e93<\/strong><\/p>\n<p>swiper.js \u662f\u4e00\u6b3e\u6d41\u884c\u7684\u8f6e\u64ad\u56fe\u5e93\uff0c\u5b83\u5141\u8bb8\u4f60\u8f7b\u677e\u521b\u5efa\u54cd\u5e94\u5f0f\u3001\u89e6\u5c4f\u53cb\u597d\u7684\u8f6e\u64ad\u56fe\u3002\u8981\u4f7f\u7528 swiper.js \u5b9e\u73b0\u8fd9\u4e00\u6548\u679c\uff0c\u4f60\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\u5728\u4f60\u7684\u9875\u9762\u4e2d\u5f15\u5165 swiper.js \u5e93\u3002<\/li>\n<li>\u521d\u59cb\u5316\u4f60\u7684\u8f6e\u64ad\u56fe\uff0c\u5e76\u8bbe\u7f6e slidesperview \u9009\u9879\u4e3a 1\uff0cpagination \u9009\u9879\u4e3a false\u3002\u8fd9\u6837\u5c06\u521b\u5efa\u4e00\u4e2a\u5355\u9875\u9762\u7684\u8f6e\u64ad\u56fe\u3002<\/li>\n<li>\u6dfb\u52a0 on.scroll \u4e8b\u4ef6\u76d1\u542c\u5668\u5230\u4f60\u7684\u8f6e\u64ad\u56fe\u4e0a\uff0c\u5e76\u5728\u5176\u4e2d\u66f4\u65b0\u6eda\u52a8\u6761\u7684\u6eda\u52a8\u9ad8\u5ea6\u3002<\/li>\n<\/ol>\n<p><strong>\u81ea\u5199\u6eda\u52a8\u529f\u80fd<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u4e0d\u60f3\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\uff0c\u4f60\u53ef\u4ee5\u81ea\u5df1\u7f16\u5199\u6eda\u52a8\u529f\u80fd\u3002\u8fd9\u9700\u8981\u4f60\u4f7f\u7528 javascript \u6765\u4fa6\u542c\u6eda\u52a8\u4e8b\u4ef6\uff0c\u5e76\u624b\u52a8\u66f4\u65b0\u9875\u9762\u6eda\u52a8\u9ad8\u5ea6\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a<\/p>\n<pre>window.addEventListener('scroll', (e) =&gt; {\n  const targetScrollHeight = window.innerHeight;\n  window.scroll(0, Math.round(window.scrollY \/ targetScrollHeight) * targetScrollHeight);\n});<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u9700\u8981\u66f4\u591a\u7684\u5de5\u4f5c\uff0c\u4f46\u5b83\u53ef\u4ee5\u8ba9\u4f60\u5bf9\u6eda\u52a8\u884c\u4e3a\u6709\u66f4\u5927\u7684\u63a7\u5236\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7528\u9f20\u6807\u6eda\u8f6e\u5b9e\u73b0\u56fa\u5b9a\u9ad8\u5ea6\u4e00\u9875\u6eda\u52a8\uff1f\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>\u5982\u4f55\u5b9e\u73b0\u9875\u9762\u9f20\u6807\u6eda\u8f6e\u6eda\u52a8\u56fa\u5b9a\u9ad8\u5ea6\u4e00\u9875\u7684\u6548\u679c\uff1f \u4f60\u9047\u5230\u7684\u8fd9\u4e2a\u95ee\u9898\u662f\u5b9e\u73b0\u4e00\u4e2a\u7c7b\u4f3c\u4e8e\u8f6e\u64ad\u56fe\u7684\u6548\u679c\uff0c\u5f53\u7528\u6237\u9f20\u6807\u6eda\u8f6e\u5411\u4e0b\u6eda\u52a8\u65f6\uff0c\u9875\u9762\u4f1a\u4ee5\u56fa\u5b9a\u9ad8\u5ea6\u5411\u4e0b\u6ed1\u52a8\u4e00\u9875\u3002\u8981\u5b9e\u73b0\u8fd9\u4e00\u6548\u679c\uff0c\u4f60\u53ef\u4ee5\u8003\u8651\u4ee5\u4e0b\u65b9\u6cd5\uff1a \u4f7f\u7528 swiper.js \u5e93 swiper.js \u662f\u4e00\u6b3e\u6d41\u884c\u7684\u8f6e\u64ad\u56fe\u5e93\uff0c\u5b83\u5141\u8bb8\u4f60\u8f7b\u677e\u521b\u5efa\u54cd\u5e94\u5f0f\u3001\u89e6\u5c4f\u53cb\u597d\u7684\u8f6e\u64ad\u56fe\u3002\u8981\u4f7f\u7528 swiper.js \u5b9e\u73b0\u8fd9\u4e00\u6548\u679c\uff0c\u4f60\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a \u5728\u4f60\u7684\u9875\u9762\u4e2d\u5f15\u5165 swiper.js \u5e93\u3002 \u521d\u59cb\u5316\u4f60\u7684\u8f6e\u64ad\u56fe\uff0c\u5e76\u8bbe\u7f6e slidesperview \u9009\u9879\u4e3a 1\uff0cpagination \u9009\u9879\u4e3a false\u3002\u8fd9\u6837\u5c06\u521b\u5efa\u4e00\u4e2a\u5355\u9875\u9762\u7684\u8f6e\u64ad\u56fe\u3002 \u6dfb\u52a0 on.scroll \u4e8b\u4ef6\u76d1\u542c\u5668\u5230\u4f60\u7684\u8f6e\u64ad\u56fe\u4e0a\uff0c\u5e76\u5728\u5176\u4e2d\u66f4\u65b0\u6eda\u52a8\u6761\u7684\u6eda\u52a8\u9ad8\u5ea6\u3002 \u81ea\u5199\u6eda\u52a8\u529f\u80fd \u5982\u679c\u4f60\u4e0d\u60f3\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\uff0c\u4f60\u53ef\u4ee5\u81ea\u5df1\u7f16\u5199\u6eda\u52a8\u529f\u80fd\u3002\u8fd9\u9700\u8981\u4f60\u4f7f\u7528 javascript \u6765\u4fa6\u542c\u6eda\u52a8\u4e8b\u4ef6\uff0c\u5e76\u624b\u52a8\u66f4\u65b0\u9875\u9762\u6eda\u52a8\u9ad8\u5ea6\u3002 \u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\uff1a window.addEventListener(&#8216;scroll&#8217;, (e) =&gt; { const targetScrollHeight = window.innerHeight; window.scroll(0, Math.round(window.scrollY \/ targetScrollHeight) * targetScrollHeight); }); \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u79cd\u65b9\u6cd5\u9700\u8981\u66f4\u591a\u7684\u5de5\u4f5c\uff0c\u4f46\u5b83\u53ef\u4ee5\u8ba9\u4f60\u5bf9\u6eda\u52a8\u884c\u4e3a\u6709\u66f4\u5927\u7684\u63a7\u5236\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7528\u9f20\u6807\u6eda\u8f6e\u5b9e\u73b0\u56fa\u5b9a\u9ad8\u5ea6\u4e00\u9875\u6eda\u52a8\uff1f\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":[16],"tags":[],"class_list":["post-27517","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27517","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=27517"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27517\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}