{"id":28223,"date":"2024-11-24T08:43:08","date_gmt":"2024-11-24T00:43:08","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28223\/"},"modified":"2024-11-24T08:43:08","modified_gmt":"2024-11-24T00:43:08","slug":"%e8%bd%ae%e6%92%ad%e5%9b%be%e6%9c%80%e5%90%8e%e4%b8%80%e9%a1%b5%e5%88%87%e6%8d%a2%e5%88%b0%e7%ac%ac%e4%b8%80%e9%a1%b5%e4%bc%9a%e9%97%aa%e5%8a%a8%e7%9a%84%e5%8e%9f%e5%9b%a0%e6%98%af%e4%bb%80%e4%b9%88","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28223\/","title":{"rendered":"\u8f6e\u64ad\u56fe\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u4f1a\u95ea\u52a8\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173146356424029.jpg\" class=\"aligncenter\" title=\"\u8f6e\u64ad\u56fe\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u4f1a\u95ea\u52a8\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" alt=\"\u8f6e\u64ad\u56fe\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u4f1a\u95ea\u52a8\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u5982\u4f55\u89e3\u51b3\uff1f\u63d2\u56fe\" \/><\/p>\n<p>\u8f6e\u64ad\u5faa\u73af\u65f6\u51fa\u73b0\u95ea\u52a8\u7684\u539f\u56e0\u8ffd\u6eaf<\/p>\n<p>\u5728\u8f6e\u64ad\u56fe\u4e2d\u4f7f\u7528 translate3d \u8fdb\u884c\u4e0b\u4e00\u9875\u5207\u6362\u65f6\uff0c\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u65f6\u4f1a\u51fa\u73b0\u95ea\u52a8\u73b0\u8c61\u3002\u8fd9\u662f\u56e0\u4e3a\u5728\u6700\u540e\u4e00\u9875\u5411\u540e\u5207\u6362\u65f6\uff0c\u5143\u7d20\u5728\u77ac\u95f4\u5df2\u7ecf\u79fb\u52a8\u5230\u4e86\u7b2c\u4e00\u9875\u7684\u4f4d\u7f6e\uff0c\u4f46\u662f\u5728\u8fc7\u6e21\u52a8\u753b\u5b8c\u6210\u4e4b\u524d\uff0c\u6d4f\u89c8\u5668\u4f1a\u7ee7\u7eed\u5c1d\u8bd5\u4ee5\u6700\u540e\u4e00\u9875\u7684\u6837\u5f0f\u6e32\u67d3\u5143\u7d20\uff0c\u5bfc\u81f4\u89c6\u89c9\u4e0a\u7684\u95ea\u52a8\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6cd5<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u95ea\u52a8\u95ee\u9898\uff0c\u53ef\u4ee5\u4fee\u6539 changeCur \u65b9\u6cd5\uff0c\u5728\u6700\u540e\u4e00\u9875\u5411\u540e\u5207\u6362\u65f6\uff0c\u5148\u5c06\u8fc7\u6e21\u65f6\u95f4\u8bbe\u4e3a 0s\uff0c\u4f7f\u5143\u7d20\u7acb\u5373\u79fb\u52a8\u5230\u7b2c\u4e00\u9875\u4f4d\u7f6e\uff0c\u7136\u540e\u5c06\u8fc7\u6e21\u65f6\u95f4\u6062\u590d\u4e3a .3s\uff0c\u518d\u8bbe\u7f6e\u5f53\u524d\u9875\u7801\u4e3a 1\u3002\u8fd9\u6837\uff0c\u6d4f\u89c8\u5668\u5728\u8fc7\u6e21\u52a8\u753b\u5b8c\u6210\u4e4b\u524d\u5c31\u4e0d\u4f1a\u5c1d\u8bd5\u6e32\u67d3\u6700\u540e\u4e00\u9875\u7684\u6837\u5f0f\u4e86\u3002<\/p>\n<p>\u4fee\u6539\u540e\u7684 changeCur \u65b9\u6cd5\uff1a<\/p>\n<pre>changeCur(add) {\n                \/\/ this.out.style.setProperty('--trans', 'transform');\n                this.con.style.transitionDuration = '.3s';\n\n                \/\/\u5207\u6362cur\u65b9\u6cd5\n                let cur = this.out.style.getPropertyValue('--cur');\n                cur = parseInt(cur);\n\n                if (add) {\n                    if (cur === this.num) {\n                        this.con.style.transitionDuration = '0s';\n                        this.setCur(0);\n                        this.con.offsetWidth;\n                        this.con.style.transitionDuration = '.3s';\n                        this.setCur(1);\n\n                    } else {\n                        this.setCur(cur + 1);\n                    }\n\n                } else {\n                    if (cur === 1) {\n                        this.con.style.transitionDuration = '0s';\n                        this.setCur(this.num + 1);\n                        this.con.offsetWidth;\n                        this.con.style.transitionDuration = '.3s';\n                        this.setCur(this.num);\n                    } else {\n                        this.setCur(cur - 1);\n                    }\n\n                }\n            }<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7b80\u5316\u8f6e\u64ad\u5b9e\u73b0<\/p>\n<p>\u9664\u4e86\u4e0a\u8ff0\u4fee\u6539\uff0c\u8fd8\u53ef\u4ee5\u91c7\u7528\u66f4\u7b80\u5355\u7684\u65b9\u6cd5\u5b9e\u73b0\u8f6e\u64ad\u529f\u80fd\uff0c\u76f4\u63a5\u4f7f\u7528 transform \u8fdb\u884c\u56fe\u7247\u5207\u6362\uff0c\u7b80\u5316\u4ee3\u7801\u903b\u8f91\u548c\u6e32\u67d3\u6d41\u7a0b\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u8f6e\u64ad\u56fe\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u4f1a\u95ea\u52a8\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff1f\u5982\u4f55\u89e3\u51b3\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>\u8f6e\u64ad\u5faa\u73af\u65f6\u51fa\u73b0\u95ea\u52a8\u7684\u539f\u56e0\u8ffd\u6eaf \u5728\u8f6e\u64ad\u56fe\u4e2d\u4f7f\u7528 translate3d \u8fdb\u884c\u4e0b\u4e00\u9875\u5207\u6362\u65f6\uff0c\u6700\u540e\u4e00\u9875\u5207\u6362\u5230\u7b2c\u4e00\u9875\u65f6\u4f1a\u51fa\u73b0\u95ea\u52a8\u73b0\u8c61\u3002\u8fd9\u662f\u56e0\u4e3a\u5728\u6700\u540e\u4e00\u9875\u5411\u540e\u5207\u6362\u65f6\uff0c\u5143\u7d20\u5728\u77ac\u95f4\u5df2\u7ecf\u79fb\u52a8\u5230\u4e86\u7b2c\u4e00\u9875\u7684\u4f4d\u7f6e\uff0c\u4f46\u662f\u5728\u8fc7\u6e21\u52a8\u753b\u5b8c\u6210\u4e4b\u524d\uff0c\u6d4f\u89c8\u5668\u4f1a\u7ee7\u7eed\u5c1d\u8bd5\u4ee5\u6700\u540e\u4e00\u9875\u7684\u6837\u5f0f\u6e32\u67d3\u5143\u7d20\uff0c\u5bfc\u81f4\u89c6\u89c9\u4e0a\u7684\u95ea\u52a8\u3002 \u89e3\u51b3\u65b9\u6cd5 \u4e3a\u4e86\u89e3\u51b3\u95ea\u52a8\u95ee\u9898\uff0c\u53ef\u4ee5\u4fee\u6539 changeCur \u65b9\u6cd5\uff0c\u5728\u6700\u540e\u4e00\u9875\u5411\u540e\u5207\u6362\u65f6\uff0c\u5148\u5c06\u8fc7\u6e21\u65f6\u95f4\u8bbe\u4e3a 0s\uff0c\u4f7f\u5143\u7d20\u7acb\u5373\u79fb\u52a8\u5230\u7b2c\u4e00\u9875\u4f4d\u7f6e\uff0c\u7136\u540e\u5c06\u8fc7\u6e21\u65f6\u95f4\u6062\u590d\u4e3a .3s\uff0c\u518d\u8bbe\u7f6e\u5f53\u524d\u9875\u7801\u4e3a 1\u3002\u8fd9\u6837\uff0c\u6d4f\u89c8\u5668\u5728\u8fc7\u6e21\u52a8\u753b\u5b8c\u6210\u4e4b\u524d\u5c31\u4e0d\u4f1a\u5c1d\u8bd5\u6e32\u67d3\u6700\u540e\u4e00\u9875\u7684\u6837\u5f0f\u4e86\u3002 \u4fee\u6539\u540e\u7684 changeCur \u65b9\u6cd5\uff1a changeCur(add) { \/\/ this.out.style.setProperty(&#8216;&#8211;trans&#8217;, &#8216;transform&#8217;); this.con.style.transitionDuration = &#8216;.3s&#8217;; \/\/\u5207\u6362cur\u65b9\u6cd5 let cur = this.out.style.getPropertyValue(&#8216;&#8211;cur&#8217;); cur = parseInt(cur); if (add) { if (cur === this.num) { this.con.style.transitionDuration = &#8216;0s&#8217;; this.setCur(0); this.con.offsetWidth; this.con.style.transitionDuration = &#8216;.3s&#8217;; this.setCur(1); } else { this.setCur(cur + 1); } } [&hellip;]<\/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-28223","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28223","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=28223"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28223\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28223"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}