{"id":31193,"date":"2024-11-25T12:59:45","date_gmt":"2024-11-25T04:59:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31193\/"},"modified":"2024-11-25T12:59:45","modified_gmt":"2024-11-25T04:59:45","slug":"%e5%be%ae%e4%bf%a1%e5%b0%8f%e7%a8%8b%e5%ba%8f%e4%b9%8banimation%e5%8a%a8%e7%94%bb%e7%9a%84%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31193\/","title":{"rendered":"\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e4banimation\u52a8\u753b\u7684\u5b9e\u73b0"},"content":{"rendered":"<p>\u672c\u6587\u4e3b\u8981\u4e3a\u5927\u5bb6\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5b9e\u73b0animation\u52a8\u753b\u7684\u65b9\u6cd5\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u4eec\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\u3002<\/p>\n<p><strong>1. \u521b\u5efa\u52a8\u753b\u5b9e\u4f8b<br \/><\/strong><\/p>\n<p><span style=\"color: #800000\">wx.createAnimation(OBJECT)<br \/><\/span><\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u52a8\u753b\u5b9e\u4f8banimation\u3002\u8c03\u7528\u5b9e\u4f8b\u7684\u65b9\u6cd5\u6765\u63cf\u8ff0\u52a8\u753b\u3002\u6700\u540e\u901a\u8fc7\u52a8\u753b\u5b9e\u4f8b\u7684export\u65b9\u6cd5\u5bfc\u51fa\u52a8\u753b\u6570\u636e\u4f20\u9012\u7ed9\u7ec4\u4ef6\u7684animation\u5c5e\u6027\u3002<br \/><strong>\u6ce8\u610f: <\/strong>export \u65b9\u6cd5\u6bcf\u6b21\u8c03\u7528\u540e\u4f1a\u6e05\u6389\u4e4b\u524d\u7684\u52a8\u753b\u64cd\u4f5c<\/p>\n<p><strong>\u52a8\u753b\u961f\u5217<br \/><\/strong><\/p>\n<p>\u8c03\u7528\u52a8\u753b\u64cd\u4f5c\u65b9\u6cd5\u540e\u8981\u8c03\u7528 step() \u6765\u8868\u793a\u4e00\u7ec4\u52a8\u753b\u5b8c\u6210\uff0c\u53ef\u4ee5\u5728\u4e00\u7ec4\u52a8\u753b\u4e2d\u8c03\u7528\u4efb\u610f\u591a\u4e2a\u52a8\u753b\u65b9\u6cd5\uff0c\u4e00\u7ec4\u52a8\u753b\u4e2d\u7684\u6240\u6709\u52a8\u753b\u4f1a\u540c\u65f6\u5f00\u59cb\uff0c\u4e00\u7ec4\u52a8\u753b\u5b8c\u6210\u540e\u624d\u4f1a\u8fdb\u884c\u4e0b\u4e00\u7ec4\u52a8\u753b\u3002step \u53ef\u4ee5\u4f20\u5165\u4e00\u4e2a\u8ddf wx.createAnimation() \u4e00\u6837\u7684\u914d\u7f6e\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u5f53\u524d\u7ec4\u52a8\u753b\u7684\u914d\u7f6e\u3002 \u901a\u8fc7\u4e8b\u4ef6\u7ed1\u5b9a\u52a8\u753b\u5373\u53ef\u8c03\u7528\u52a8\u753b\u6267\u884c\u3002<\/p>\n<p>\u521b\u5efa\u7684\u52a8\u753b\u5b9e\u4f8b\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u52a8\u753b\u65b9\u6cd5\u8fdb\u884c\u63cf\u8ff0\uff0c\u8c03\u7528\u7ed3\u675f\u540e\u4f1a\u8fd4\u56de\u81ea\u8eab\uff0c\u652f\u6301\u94fe\u5f0f\u8c03\u7528\u7684\u5199\u6cd5\u3002<br \/>\u5728\u540c\u4e00\u4e2a\u52a8\u753b\u5b9e\u4f8b\u5185\u90e8\uff0c\u53ef\u4ee5\u5b9a\u4e49\u591a\u79cd\u8fd0\u52a8\u5f62\u5f0f\uff0c\u5e76\u5b9a\u4e49\u591a\u4e2a\u52a8\u753b\u7ed1\u5b9a\u5230\u4e0d\u540c\u6807\u7b7e<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>animation1:&nbsp;{}\r\nanimation2:&nbsp;{}\r\n\r\ntouch:&nbsp;function&nbsp;()&nbsp;{\r\n&nbsp;let&nbsp;animation1&nbsp;=&nbsp;wx.createAnimation({\r\n&nbsp;&nbsp;transformOrigin:&nbsp;\"50%&nbsp;50%\",\r\n&nbsp;&nbsp;duration:&nbsp;1000,\r\n&nbsp;&nbsp;timingFunction:&nbsp;\"ease\",\r\n&nbsp;&nbsp;delay:&nbsp;0\r\n&nbsp;});\r\n&nbsp;animation1.translateX(-app.globalData.windowWidth&nbsp;*&nbsp;0.7).step({&nbsp;duration:&nbsp;1000&nbsp;});\r\n&nbsp;this.setData({\r\n&nbsp;&nbsp;animation1:&nbsp;animation1.export()\r\n&nbsp;});\r\n&nbsp;let&nbsp;animation2&nbsp;=&nbsp;wx.createAnimation({\r\n&nbsp;&nbsp;transformOrigin:&nbsp;\"50%&nbsp;50%\",\r\n&nbsp;&nbsp;duration:&nbsp;1000,\r\n&nbsp;&nbsp;timingFunction:&nbsp;\"ease\",\r\n&nbsp;&nbsp;delay:&nbsp;0\r\n&nbsp;});\r\n&nbsp;animation2.opacity(0.7).step({&nbsp;duration:&nbsp;1000&nbsp;});\r\n&nbsp;this.setData({\r\n&nbsp;&nbsp;animation2:&nbsp;animation2.export()\r\n&nbsp;});\r\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u8c03\u7528\u52a8\u753b\u6267\u884c<br \/><\/strong><\/p>\n<p><span style=\"color: #800000\"><strong>2.1 \u7ed1\u5b9a\u52a8\u753b<\/strong><\/span><\/p>\n<p>\u5c06\u6240\u521b\u5efa\u7684\u52a8\u753b\u5b9e\u4f8b\u7ed1\u5b9a\u5230\u76f8\u5e94\u6807\u7b7e<\/p>\n<p>\u793a\u4f8b\u4ee3\u7801<\/p>\n<pre>&lt;view&gt;&lt;\/view&gt;&lt;view&gt;&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><span style=\"color: #800000\"><strong>2.2 \u89e6\u53d1\u52a8\u753b<\/strong><\/span><\/p>\n<p>\u901a\u8fc7\u9875\u9762\u4e8b\u4ef6\u8c03\u7528\u52a8\u753b\u6267\u884c<\/p>\n<p>\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;view&gt;&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u76f8\u5173\u63a8\u8350\uff1a<\/p>\n<\/p>\n<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u4e4banimation\u52a8\u753b\u7684\u5b9e\u73b0\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>\u672c\u6587\u4e3b\u8981\u4e3a\u5927\u5bb6\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5b9e\u73b0animation\u52a8\u753b\u7684\u65b9\u6cd5\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u4eec\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\uff0c\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\u3002 1. \u521b\u5efa\u52a8\u753b\u5b9e\u4f8b wx.createAnimation(OBJECT) \u521b\u5efa\u4e00\u4e2a\u52a8\u753b\u5b9e\u4f8banimation\u3002\u8c03\u7528\u5b9e\u4f8b\u7684\u65b9\u6cd5\u6765\u63cf\u8ff0\u52a8\u753b\u3002\u6700\u540e\u901a\u8fc7\u52a8\u753b\u5b9e\u4f8b\u7684export\u65b9\u6cd5\u5bfc\u51fa\u52a8\u753b\u6570\u636e\u4f20\u9012\u7ed9\u7ec4\u4ef6\u7684animation\u5c5e\u6027\u3002\u6ce8\u610f: export \u65b9\u6cd5\u6bcf\u6b21\u8c03\u7528\u540e\u4f1a\u6e05\u6389\u4e4b\u524d\u7684\u52a8\u753b\u64cd\u4f5c \u52a8\u753b\u961f\u5217 \u8c03\u7528\u52a8\u753b\u64cd\u4f5c\u65b9\u6cd5\u540e\u8981\u8c03\u7528 step() \u6765\u8868\u793a\u4e00\u7ec4\u52a8\u753b\u5b8c\u6210\uff0c\u53ef\u4ee5\u5728\u4e00\u7ec4\u52a8\u753b\u4e2d\u8c03\u7528\u4efb\u610f\u591a\u4e2a\u52a8\u753b\u65b9\u6cd5\uff0c\u4e00\u7ec4\u52a8\u753b\u4e2d\u7684\u6240\u6709\u52a8\u753b\u4f1a\u540c\u65f6\u5f00\u59cb\uff0c\u4e00\u7ec4\u52a8\u753b\u5b8c\u6210\u540e\u624d\u4f1a\u8fdb\u884c\u4e0b\u4e00\u7ec4\u52a8\u753b\u3002step \u53ef\u4ee5\u4f20\u5165\u4e00\u4e2a\u8ddf wx.createAnimation() \u4e00\u6837\u7684\u914d\u7f6e\u53c2\u6570\u7528\u4e8e\u6307\u5b9a\u5f53\u524d\u7ec4\u52a8\u753b\u7684\u914d\u7f6e\u3002 \u901a\u8fc7\u4e8b\u4ef6\u7ed1\u5b9a\u52a8\u753b\u5373\u53ef\u8c03\u7528\u52a8\u753b\u6267\u884c\u3002 \u521b\u5efa\u7684\u52a8\u753b\u5b9e\u4f8b\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528\u52a8\u753b\u65b9\u6cd5\u8fdb\u884c\u63cf\u8ff0\uff0c\u8c03\u7528\u7ed3\u675f\u540e\u4f1a\u8fd4\u56de\u81ea\u8eab\uff0c\u652f\u6301\u94fe\u5f0f\u8c03\u7528\u7684\u5199\u6cd5\u3002\u5728\u540c\u4e00\u4e2a\u52a8\u753b\u5b9e\u4f8b\u5185\u90e8\uff0c\u53ef\u4ee5\u5b9a\u4e49\u591a\u79cd\u8fd0\u52a8\u5f62\u5f0f\uff0c\u5e76\u5b9a\u4e49\u591a\u4e2a\u52a8\u753b\u7ed1\u5b9a\u5230\u4e0d\u540c\u6807\u7b7e \u793a\u4f8b\u4ee3\u7801\uff1a animation1:&nbsp;{} animation2:&nbsp;{} touch:&nbsp;function&nbsp;()&nbsp;{ &nbsp;let&nbsp;animation1&nbsp;=&nbsp;wx.createAnimation({ &nbsp;&nbsp;transformOrigin:&nbsp;&#8220;50%&nbsp;50%&#8221;, &nbsp;&nbsp;duration:&nbsp;1000, &nbsp;&nbsp;timingFunction:&nbsp;&#8220;ease&#8221;, &nbsp;&nbsp;delay:&nbsp;0 &nbsp;}); &nbsp;animation1.translateX(-app.globalData.windowWidth&nbsp;*&nbsp;0.7).step({&nbsp;duration:&nbsp;1000&nbsp;}); &nbsp;this.setData({ &nbsp;&nbsp;animation1:&nbsp;animation1.export() &nbsp;}); &nbsp;let&nbsp;animation2&nbsp;=&nbsp;wx.createAnimation({ &nbsp;&nbsp;transformOrigin:&nbsp;&#8220;50%&nbsp;50%&#8221;, &nbsp;&nbsp;duration:&nbsp;1000, &nbsp;&nbsp;timingFunction:&nbsp;&#8220;ease&#8221;, &nbsp;&nbsp;delay:&nbsp;0 &nbsp;}); &nbsp;animation2.opacity(0.7).step({&nbsp;duration:&nbsp;1000&nbsp;}); &nbsp;this.setData({ &nbsp;&nbsp;animation2:&nbsp;animation2.export() &nbsp;}); } \u767b\u5f55\u540e\u590d\u5236 2. \u8c03\u7528\u52a8\u753b\u6267\u884c 2.1 \u7ed1\u5b9a\u52a8\u753b \u5c06\u6240\u521b\u5efa\u7684\u52a8\u753b\u5b9e\u4f8b\u7ed1\u5b9a\u5230\u76f8\u5e94\u6807\u7b7e \u793a\u4f8b\u4ee3\u7801 &lt;view&gt;&lt;\/view&gt;&lt;view&gt;&lt;\/view&gt; \u767b\u5f55\u540e\u590d\u5236 2.2 \u89e6\u53d1\u52a8\u753b \u901a\u8fc7\u9875\u9762\u4e8b\u4ef6\u8c03\u7528\u52a8\u753b\u6267\u884c \u793a\u4f8b\u4ee3\u7801\uff1a &lt;view&gt;&lt;\/view&gt; [&hellip;]<\/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-31193","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31193","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=31193"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31193\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31193"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}