{"id":31439,"date":"2024-11-25T13:34:36","date_gmt":"2024-11-25T05:34:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31439\/"},"modified":"2024-11-25T13:34:36","modified_gmt":"2024-11-25T05:34:36","slug":"%e5%9c%a8%e5%b0%8f%e7%a8%8b%e5%ba%8f%e9%87%8c%e5%ae%9e%e7%8e%b0animation%e5%8a%a8%e7%94%bb","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31439\/","title":{"rendered":"\u5728\u5c0f\u7a0b\u5e8f\u91cc\u5b9e\u73b0animation\u52a8\u753b"},"content":{"rendered":"<p style=\"text-align: left\">\u8fd9\u6b21\u7ed9\u5927\u5bb6\u5e26\u6765\u5728\u5c0f\u7a0b\u5e8f\u91cc\u5b9e\u73b0animation\uff0c\u5728\u5c0f\u7a0b\u5e8f\u91cc\u5b9e\u73b0animation\u52a8\u753b\u7684\u6709\u54ea\u4e9b\uff0c\u4e0b\u9762\u5c31\u662f\u5b9e\u6218\u6848\u4f8b\uff0c\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002<\/p>\n<p style=\"text-align: left\">\u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5b9e\u73b0animation\u52a8\u753b\uff0c\u5177\u4f53\u5185\u5bb9\u5982\u4e0b<\/p>\n<p style=\"text-align: left\"><strong>1. \u521b\u5efa\u52a8\u753b\u5b9e\u4f8b<\/strong><\/p>\n<p style=\"text-align: left\"><span style=\"color: #800000\">wx.createAnimation()<\/span><\/p>\n<p style=\"text-align: left\">\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\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 style=\"text-align: left\"><strong>\u52a8\u753b\u961f\u5217<\/strong><\/p>\n<p style=\"text-align: left\">\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\u7ed1\u5b9a\u52a8\u753b\u5373\u53ef\u8c03\u7528\u52a8\u753b\u6267\u884c\u3002<\/p>\n<p style=\"text-align: left\">\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 style=\"text-align: left\"><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<pre>animation1: {}\r\nanimation2: {}\r\ntouch: function () {\r\n let animation1 = wx.createAnimation({\r\n  transformOrigin: \"50% 50%\",\r\n  duration: 1000,\r\n  timingFunction: \"ease\",\r\n  delay: 0\r\n });\r\n animation1.translateX(-app.globalData.windowWidth * 0.7).step({ duration: 1000 });\r\n this.setData({\r\n  animation1: animation1.export()\r\n });\r\n let animation2 = wx.createAnimation({\r\n  transformOrigin: \"50% 50%\",\r\n  duration: 1000,\r\n  timingFunction: \"ease\",\r\n  delay: 0\r\n });\r\n animation2.opacity(0.7).step({ duration: 1000 });\r\n this.setData({\r\n  animation2: animation2.export()\r\n });\r\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align: left\"><strong>2. \u8c03\u7528\u52a8\u753b\u6267\u884c<\/strong><\/p>\n<p style=\"text-align: left\"><span style=\"color: #800000\"><strong>2.1 \u7ed1\u5b9a\u52a8\u753b<\/strong><\/span><\/p>\n<p style=\"text-align: left\">\u5c06\u6240\u521b\u5efa\u7684\u52a8\u753b\u5b9e\u4f8b\u7ed1\u5b9a\u5230\u76f8\u5e94\u6807\u7b7e<\/p>\n<p style=\"text-align: left\">\u793a\u4f8b\u4ee3\u7801<\/p>\n<pre>&lt;view animation=\"{{animation1}}\"&gt;&lt;\/view&gt;\r\n&lt;view animation=\"{{animation2}}\"&gt;&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p style=\"text-align: left\"><span style=\"color: #800000\"><strong>2.2 \u89e6\u53d1\u52a8\u753b<\/strong><\/span><\/p>\n<p style=\"text-align: left\">\u901a\u8fc7\u9875\u9762\u4e8b\u4ef6\u8c03\u7528\u52a8\u753b\u6267\u884c<\/p>\n<p style=\"text-align: left\">\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;view bindtap=\"touch\"&gt;&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u76f8\u4fe1\u770b\u4e86\u672c\u6587\u6848\u4f8b\u4f60\u5df2\u7ecf\u638c\u63e1\u4e86\u65b9\u6cd5\uff0c\u66f4\u591a\u7cbe\u5f69\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n<p>\u63a8\u8350\u9605\u8bfb\uff1a<\/p>\n<\/p>\n<p style=\"text-align: left\"><\/p>\n<p style=\"text-align: left\"><\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728\u5c0f\u7a0b\u5e8f\u91cc\u5b9e\u73b0animation\u52a8\u753b\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>\u8fd9\u6b21\u7ed9\u5927\u5bb6\u5e26\u6765\u5728\u5c0f\u7a0b\u5e8f\u91cc\u5b9e\u73b0animation\uff0c\u5728\u5c0f\u7a0b\u5e8f\u91cc\u5b9e\u73b0animation\u52a8\u753b\u7684\u6709\u54ea\u4e9b\uff0c\u4e0b\u9762\u5c31\u662f\u5b9e\u6218\u6848\u4f8b\uff0c\u4e00\u8d77\u6765\u770b\u4e00\u4e0b\u3002 \u5fae\u4fe1\u5c0f\u7a0b\u5e8f\u5b9e\u73b0animation\u52a8\u753b\uff0c\u5177\u4f53\u5185\u5bb9\u5982\u4e0b 1. \u521b\u5efa\u52a8\u753b\u5b9e\u4f8b wx.createAnimation() \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\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\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: {} animation2: {} touch: function () { let animation1 = wx.createAnimation({ transformOrigin: &#8220;50% 50%&#8221;, duration: 1000, timingFunction: &#8220;ease&#8221;, delay: 0 }); animation1.translateX(-app.globalData.windowWidth * 0.7).step({ duration: 1000 }); this.setData({ animation1: animation1.export() }); let animation2 = wx.createAnimation({ transformOrigin: [&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-31439","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31439","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=31439"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31439\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}