{"id":28348,"date":"2024-11-24T13:32:31","date_gmt":"2024-11-24T05:32:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28348\/"},"modified":"2024-11-24T13:32:31","modified_gmt":"2024-11-24T05:32:31","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%9b%9e%e7%ac%ac%e4%b8%80%e9%a1%b5%e6%97%b6%e5%9b%be%e7%89%87%e9%97%aa%e5%8a%a8%e6%80%8e%e4%b9%88%e5%8a%9e%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28348\/","title":{"rendered":"\u8f6e\u64ad\u56fe\u6700\u540e\u4e00\u9875\u5207\u6362\u56de\u7b2c\u4e00\u9875\u65f6\u56fe\u7247\u95ea\u52a8\u600e\u4e48\u529e\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173156167245259.jpg\" class=\"aligncenter\" title=\"\u8f6e\u64ad\u56fe\u6700\u540e\u4e00\u9875\u5207\u6362\u56de\u7b2c\u4e00\u9875\u65f6\u56fe\u7247\u95ea\u52a8\u600e\u4e48\u529e\uff1f\u63d2\u56fe\" alt=\"\u8f6e\u64ad\u56fe\u6700\u540e\u4e00\u9875\u5207\u6362\u56de\u7b2c\u4e00\u9875\u65f6\u56fe\u7247\u95ea\u52a8\u600e\u4e48\u529e\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u8f6e\u64ad\u5faa\u73af\u65f6\u56fe\u7247\u95ea\u52a8\u7684\u6839\u6e90<\/strong><\/p>\n<p>\u5728\u8f6e\u64ad\u56fe\u4e2d\uff0c\u5f53\u7528\u6237\u5728\u6700\u540e\u4e00\u9875\u5207\u6362\u56de\u7b2c\u4e00\u9875\u65f6\u4f1a\u51fa\u73b0\u56fe\u7247\u95ea\u52a8\u73b0\u8c61\u3002\u8fd9\u662f\u56e0\u4e3a\u5728\u4f7f\u7528 translate3d \u8fdb\u884c\u9875\u9762\u5207\u6362\u65f6\uff0c\u5f53\u5373\u5c06\u5207\u6362\u56de\u7b2c\u4e00\u9875\u65f6\uff0c\u9875\u9762\u4f1a\u77ac\u95f4\u6d88\u5931\u518d\u51fa\u73b0\uff0c\u5bfc\u81f4\u95ea\u70c1\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u9488\u5bf9\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u5bf9 JavaScript \u4ee3\u7801\u8fdb\u884c\u8c03\u6574\uff0c\u5177\u4f53\u5982\u4e0b\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        \/\/ this.setCur(cur+1);\n\n        \/\/ if(cur &gt; this.num-1){\n        \/\/     setTimeout(() =&gt; {\n        \/\/         \/\/ cur = 1;\n        \/\/         \/\/ this.out.style.setProperty('--trans', 'none');\n        \/\/         this.con.style.transitionDuration = '0s';\n        \/\/         this.setCur(1);\n        \/\/     }, 300)\n        \/\/ }\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    }\n    else{\n        \/\/ this.setCur(cur-1);\n        \/\/ if(cur &lt; 2){\n        \/\/     \/\/ setTimeout(() =&gt; {\n        \/\/     \/\/     \/\/ cur = this.num;\n        \/\/     \/\/     \/\/ this.out.style.setProperty('--trans', 'none');\n        \/\/     \/\/     this.con.style.transitionDuration = '0s';\n        \/\/     \/\/     this.setCur(this.num);\n        \/\/     \/\/ }, 300)\n        \/\/ }\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>\u4ee5\u4e0a\u5c31\u662f\u8f6e\u64ad\u56fe\u6700\u540e\u4e00\u9875\u5207\u6362\u56de\u7b2c\u4e00\u9875\u65f6\u56fe\u7247\u95ea\u52a8\u600e\u4e48\u529e\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\u56fe\u7247\u95ea\u52a8\u7684\u6839\u6e90 \u5728\u8f6e\u64ad\u56fe\u4e2d\uff0c\u5f53\u7528\u6237\u5728\u6700\u540e\u4e00\u9875\u5207\u6362\u56de\u7b2c\u4e00\u9875\u65f6\u4f1a\u51fa\u73b0\u56fe\u7247\u95ea\u52a8\u73b0\u8c61\u3002\u8fd9\u662f\u56e0\u4e3a\u5728\u4f7f\u7528 translate3d \u8fdb\u884c\u9875\u9762\u5207\u6362\u65f6\uff0c\u5f53\u5373\u5c06\u5207\u6362\u56de\u7b2c\u4e00\u9875\u65f6\uff0c\u9875\u9762\u4f1a\u77ac\u95f4\u6d88\u5931\u518d\u51fa\u73b0\uff0c\u5bfc\u81f4\u95ea\u70c1\u3002 \u89e3\u51b3\u65b9\u6848 \u9488\u5bf9\u6b64\u95ee\u9898\uff0c\u53ef\u4ee5\u5bf9 JavaScript \u4ee3\u7801\u8fdb\u884c\u8c03\u6574\uff0c\u5177\u4f53\u5982\u4e0b\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){ \/\/ this.setCur(cur+1); \/\/ if(cur &gt; this.num-1){ \/\/ setTimeout(() =&gt; { \/\/ \/\/ cur = 1; \/\/ \/\/ this.out.style.setProperty(&#8216;&#8211;trans&#8217;, &#8216;none&#8217;); \/\/ this.con.style.transitionDuration = &#8216;0s&#8217;; \/\/ this.setCur(1); \/\/ }, 300) \/\/ } if [&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-28348","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28348","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=28348"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28348\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}