{"id":28573,"date":"2024-11-25T17:22:57","date_gmt":"2024-11-25T09:22:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28573\/"},"modified":"2024-11-25T17:22:57","modified_gmt":"2024-11-25T09:22:57","slug":"%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e5%b0%8f%e7%a8%8b%e5%ba%8f%e5%8a%a8%e7%94%bb%ef%bc%9f%e5%b0%8f%e7%a8%8b%e5%ba%8f%e5%8a%a8%e7%94%bb%e7%9a%84%e5%ae%9e%e7%8e%b0%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28573\/","title":{"rendered":"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5"},"content":{"rendered":"<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u5185\u5bb9\u662f\u4ecb\u7ecd\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u6709\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u4f60\u4eec\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u5728\u666e\u901a\u7684\u7f51\u9875\u5f00\u53d1\u4e2d\uff0c\u52a8\u753b\u6548\u679c\u53ef\u4ee5\u901a\u8fc73\u6765\u5b9e\u73b0\u5927\u90e8\u5206\u9700\u6c42\uff0c\u5728\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u4e2d\u540c\u6837\u53ef\u4ee5\u4f7f\u7528css3\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u901a\u8fc7api\u65b9\u5f0f\u6765\u5b9e\u73b0\u3002<\/p>\n<p><strong><span style=\"font-size: 24px\">API\u89e3\u8bfb<\/span><\/strong><\/p>\n<p>\u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u901a\u8fc7\u8c03\u7528api\u6765\u521b\u5efa\u52a8\u753b\uff0c\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\u3002\u8fd9\u4e2a\u5bf9\u8c61\u901a\u8fc7wx.createAnimation\u8fd4\u56de,animation\u7684\u4e00\u7cfb\u5217\u5c5e\u6027\u90fd\u57fa\u4e8e\u8fd9\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\u3002<\/p>\n<p><strong><span style=\"font-size: 16px\">\u521b\u5efa\u8fd9\u4e2a\u5bf9\u8c61<\/span><\/strong><\/p>\n<pre>    let animation = wx.createAnimation({\n        duration: 2000,\n        delay: 0,\n        timingFunction: \"linear\",\n    });<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u4e2aanimation\u5c31\u662f\u901a\u8fc7wx.createAnimation\u4e4b\u540e\u8fd4\u56de\u7684\u5b9e\u4f8b\u3002\u5728\u521b\u5efa\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u7ed9\u8fd9\u4e2a\u5b9e\u4f8b\u6dfb\u52a0\u4e00\u4e9b\u5c5e\u6027\uff0c\u5982\u4ee5\u4e0a\u4ee3\u7801\u6240\u793a\uff0c\u7b49\u540c\u4e8ecss3\u4e2danimation:$name 2s linear\u7684\u5199\u6cd5\u3002<\/p>\n<p><strong><span style=\"font-size: 16px\">\u6dfb\u52a0\u52a8\u6548<\/span><\/strong><\/p>\n<p>\u5b9e\u4f8b\u521b\u5efa\u5b8c\u6210\u4e4b\u540e\uff0c\u57fa\u4e8e\u8be5\u5b9e\u4f8b\uff0c\u6dfb\u52a0\u9700\u8981\u7684\u52a8\u6001\u6548\u679c\uff0c\u52a8\u6001\u7c7b\u578b\u53ef\u4ee5\u67e5\u9605\u6587\u6863\u5f97\u77e5\uff0c\u4ee5\u6700\u5e38\u89c1\u7684\u79fb\u52a8\uff0c\u65cb\u8f6c\u4e3a\u4f8b\uff1a<\/p>\n<pre>    animation.translate($width, 0).rotate($deg);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong><span style=\"font-size: 16px\">\u7ed3\u675f\u52a8\u753b<\/span><\/strong><\/p>\n<p>.step()\u8868\u793a\u4e00\u7ec4\u52a8\u753b\u7684\u7ed3\u675f<\/p>\n<pre>    animation.step();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong><span style=\"font-size: 16px\">\u5bfc\u51fa\u52a8\u753b<\/span><\/strong><\/p>\n<p>\u52a8\u753b\u6548\u679c\u6dfb\u52a0\u5b8c\u6210\u4e86\uff0c\u5982\u4f55\u7ed9\u60f3\u8981\u7684dom\u6dfb\u52a0\u52a8\u6548\u5462\u3002\u8fd9\u91cc\u9700\u8981\u7528\u5230.export()\u5bfc\u51fa\u52a8\u753b\u961f\u5217\uff0c\u8d4b\u503c\u7ed9\u67d0\u4e2adom\u5bf9\u8c61\u3002<\/p>\n<pre>    this.setData({ moveOne: animation.export() })<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>    &lt;view  animation=\"{{moveOne}}\"&gt;&lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong><span style=\"font-size: 24px\">\u4f8b\u5b50<\/span><\/strong><\/p>\n<p>\u4ee5\u4e0b\u5c06\u901a\u8fc72\u7ec4\u52a8\u753b\uff0c\u6765\u5bf9\u6bd4\u4e00\u4e0bcss3\u4e0eapi\u5b9e\u73b0\u65b9\u5f0f\u7684\u4e0d\u540c\u3002<\/p>\n<p><strong><span style=\"font-size: 16px\">\u4e00\u3001\u6a21\u5757\u79fb\u52a8\u52a8\u753b<\/span><\/strong><\/p>\n<p><strong>\u52a8\u753b\u6548\u679c\uff1a<\/strong><\/p>\n<p>\u4e0b\u56fe\u6709\u4e24\u7ec4\u52a8\u753b\uff0c\u5206\u522b\u4e3aapi\u65b9\u5f0f\uff08\u4e0a\uff09\u4e0ecss3\u65b9\u5f0f\uff08\u4e0b\uff09\u5b8c\u6210\u7684\u6548\u679c\uff0c\u70b9\u51fbmove\u6309\u94ae\uff0c\u52a8\u753b\u542f\u52a8\u3002<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/\/upload\/image\/217\/139\/254\/1541838750247269.gif\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe\" alt=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4ee3\u7801\u5b9e\u73b0<\/strong><\/p>\n<p>\u4ee5\u4e0b\u5206\u522b\u4e3acss3\u4e0eapi\u7684\u6838\u5fc3\u4ee3\u7801\uff1a<\/p>\n<p><strong><span style=\"font-size: 12px\">css3\uff1a<\/span><\/strong><\/p>\n<pre>    &lt;!-- wxml --&gt;\n    &lt;view class='border'&gt;\n        &lt;view class='css-block {{isMove &amp;&amp; \"one\"}}'&gt;&lt;\/view&gt;\n        &lt;view class='css-block {{isMove &amp;&amp; \"two\"}}'&gt;&lt;\/view&gt;\n        &lt;view class='css-block {{isMove &amp;&amp; \"three\"}}'&gt;&lt;\/view&gt;\n        &lt;view class='css-block {{isMove &amp;&amp; \"four\"}}'&gt;&lt;\/view&gt;\n    &lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>    \/\/ scss\n    @mixin movePublic($oldLeft,$oldTop,$left,$top) {\n        from {\n          transform:translate($oldLeft,$oldTop);\n        }\n        to {\n          transform:translate($left,$top);\n        }\n    }\n    \n    @mixin blockStyle($color,$name) {\n        background: $color;\n        animation:$name 2s linear infinite alternate;\n    }\n    .one {\n        @include blockStyle(lightsalmon,onemove);\n    }\n    \n    @keyframes onemove {\n        @include movePublic(50rpx,-25rpx,-150rpx,0rpx);\n    }\n    \n    .two {\n        @include blockStyle(lightblue,twomove);\n    }\n    \n    @keyframes twomove {\n        @include movePublic(0rpx,25rpx,-50rpx,0rpx);\n    }\n    \n    .three {\n        @include blockStyle(lightgray,threemove);\n    }\n    \n    @keyframes threemove {\n        @include movePublic(0rpx,25rpx,50rpx,0rpx);\n    }\n    \n    .four {\n        @include blockStyle(grey,fourmove);\n    }\n    \n    @keyframes fourmove {\n        @include movePublic(-50rpx,-25rpx,150rpx,0rpx);\n    }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>    \/\/ js\n    moveFunction(){\n        this.setData({\n            isMove: true\n        })\n    }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>css3\u4e2d\u901a\u8fc7\u52a8\u6001\u6539\u53d8class\u7c7b\u540d\u6765\u8fbe\u5230\u52a8\u753b\u7684\u6548\u679c\uff0c\u5982\u4e0a\u4ee3\u7801\u901a\u8fc7one\u3001two\u3001three\u3001four\u6765\u5206\u522b\u63a7\u5236\u79fb\u52a8\u7684\u8ddd\u79bb\uff0c\u901a\u8fc7sass\u53ef\u4ee5\u907f\u514d\u4ee3\u7801\u8fc7\u4e8e\u5197\u4f59\u7684\u95ee\u9898\u3002<strong>\uff08\u7ea0\u7ed3\u5982\u4f55\u5728\u5c0f\u7a0b\u5e8f\u4e2d\u4f7f\u7528sass\u7684\u7ae5\u978b\u8bf7\u770b\u8fd9\u91cc\u54e6\uff1awechat-mina-template\uff09<\/strong><\/p>\n<p><strong><span style=\"font-size: 12px\">api\uff1a<\/span><\/strong><\/p>\n<pre>    moveClick(){\n        this.move(-75,-12.5,25,'moveOne');\n        this.move(-25,12.5, 0,'moveTwo');\n        this.move(25, 12.5,0,'moveThree');\n        this.move(75, -12.5,-25,'moveFour');\n        this.moveFunction(); \/\/ \u8be5\u4e8b\u4ef6\u89e6\u53d1css3\u6a21\u5757\u8fdb\u884c\u79fb\u52a8\n    },\n\n    \/\/ \u6a21\u5757\u79fb\u52a8\u65b9\u6cd5\n    move: function (w,h,m,ele) {\n        let self = this;\n        let moveFunc = function () {\n        let animation = wx.createAnimation({\n            duration: 2000,\n            delay: 0,\n            timingFunction: \"linear\",\n        });\n    \n        animation.translate(w, 0).step()\n        self.setData({ [ele]: animation.export() })\n        let timeout = setTimeout(function () {\n            animation.translate(m, h).step();\n            self.setData({\n                \/\/ [ele] \u4ee3\u8868\u9700\u8981\u7ed1\u5b9a\u52a8\u753b\u7684\u6570\u7ec4\u5bf9\u8c61\n                [ele]: animation.export()\n            })\n          }.bind(this), 2000)\n        }\n        moveFunc();\n        let interval = setInterval(moveFunc,4000)\n    }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6548\u679c\u56fe\u53ef\u89c1\uff0c\u6a21\u5757\u4e4b\u95f4\u90fd\u662f\u7b80\u5355\u7684\u79fb\u52a8\uff0c\u53ef\u4ee5\u5c06\u4ed6\u4eec\u7684\u8fd0\u52a8\u53d8\u5316\u5199\u6210\u4e00\u4e2a\u516c\u5171\u7684\u4e8b\u4ef6\uff0c\u901a\u8fc7\u5411\u4e8b\u4ef6\u4f20\u503c\uff0c\u6765\u79fb\u52a8\u5230\u4e0d\u540c\u7684\u4f4d\u7f6e\u3002\u5176\u4e2d\u7684\u53c2\u6570w,h,m,ele\u5206\u522b\u8868\u793a\u53d1\u6563\u6c34\u5e73\u65b9\u5411\u79fb\u52a8\u7684\u8ddd\u79bb\u3001\u805a\u62e2\u65f6\u5782\u76f4\u65b9\u5411\u3001\u6c34\u5e73\u65b9\u5411\u7684\u8ddd\u79bb\u4ee5\u53ca\u9700\u8981\u4fee\u6539animationData\u7684\u5bf9\u8c61\u3002<\/p>\n<p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\u4ea7\u751f\u7684\u52a8\u753b\uff0c\u65e0\u6cd5\u6309\u7167\u539f\u6709\u8f68\u8ff9\u6536\u56de\uff0c\u6240\u4ee5\u5728\u4e8b\u4ef6\u4e4b\u540e\u8bbe\u7f6e\u4e86\u5b9a\u65f6\u5668\uff0c\u5b9a\u4e49\u5728\u6267\u884c\u52a8\u753b2s\u4e4b\u540e\uff0c\u6267\u884c\u53e6\u4e00\u4e2a\u52a8\u753b\u3002\u540c\u65f6<strong>\u52a8\u753b\u53ea\u80fd\u6267\u884c\u4e00\u6b21<\/strong>\uff0c\u5982\u679c\u9700\u8981\u5faa\u73af\u7684\u52a8\u6548\uff0c\u8981\u5728\u5916\u5c42\u5305\u88f9\u4e00\u4e2a\u91cd\u590d\u6267\u884c\u7684\u5b9a\u65f6\u5668\u5230\u3002<\/p>\n<p>\u67e5\u770b\u6e90\u7801\uff0c\u53d1\u73b0api\u65b9\u5f0f\u662f\u901a\u8fc7js\u63d2\u5165\u5e76\u6539\u53d8\u5185\u8054\u6837\u5f0f\u6765\u8fbe\u5230\u52a8\u753b\u6548\u679c\uff0c\u4e0b\u9762\u8fd9\u5f20\u52a8\u56fe\u53ef\u4ee5\u6e05\u6670\u5730\u770b\u51fa\u6837\u5f0f\u53d8\u5316\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/\/upload\/image\/402\/553\/276\/1541838911474985.gif\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe1\" alt=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe1\" \/><\/p>\n<p>\u6253\u5370\u51fa\u8d4b\u503c\u7684animationData\uff0canimates\u4e2d\u5b58\u653e\u4e86\u52a8\u753b\u4e8b\u4ef6\u7684\u7c7b\u578b\u53ca\u53c2\u6570\uff1boptions\u4e2d\u5b58\u653e\u7684\u662f\u6b64\u6b21\u52a8\u753b\u7684\u914d\u7f6e\u9009\u9879\uff0ctransition\u4e2d\u5b58\u653e\u7684\u662fwx.createAnimation\u8c03\u7528\u65f6\u7684\u914d\u7f6e\uff0ctransformOrigin\u662f\u9ed8\u8ba4\u914d\u7f6e\uff0c\u610f\u4e3a\u4ee5\u5bf9\u8c61\u7684\u4e2d\u5fc3\u4e3a\u8d77\u70b9\u5f00\u59cb\u6267\u884c\u52a8\u753b\uff0c\u4e5f\u53ef\u5728wx.createAnimation\u65f6\u8fdb\u884c\u914d\u7f6e\u3002<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/\/upload\/image\/522\/900\/540\/1541838924735924.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe2\" alt=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe2\" \/><\/p>\n<p><strong><span style=\"font-size: 16px\">\u4e8c\u3001\u97f3\u4e50\u64ad\u653e\u52a8\u753b<\/span><\/strong><\/p>\n<p>\u4e0a\u9762\u7684\u6a21\u5757\u79fb\u52a8\u52a8\u753b\u4e0d\u6d89\u53ca\u903b\u8f91\u4ea4\u4e92\uff0c\u56e0\u6b64\u65b0\u5c1d\u8bd5\u4e86\u4e00\u4e2a\u97f3\u4e50\u64ad\u653e\u52a8\u753b\uff0c\u8be5\u52a8\u753b\u9700\u8981\u5b9e\u73b0\u6682\u505c\u3001\u7ee7\u7eed\u7684\u6548\u679c\u3002<\/p>\n<p><strong>\u52a8\u753b\u6548\u679c\uff1a<\/strong><\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/\/upload\/image\/858\/455\/879\/1541838930811570.gif\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe3\" alt=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe3\" \/><\/p>\n<p>\u4e24\u7ec4\u4e0d\u540c\u7684\u52a8\u753b\u6548\u679c\u5bf9\u6bd4\uff0c\u5206\u522b\u4e3aapi\uff08\u4e0a\uff09\u5b9e\u73b0\u4e0ecss3\u5b9e\u73b0\uff08\u4e0b\uff09\uff1a<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/\/upload\/image\/150\/820\/634\/1541838939986105.gif\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe4\" alt=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe4\" \/><\/p>\n<p><strong>\u4ee3\u7801\u5b9e\u73b0<\/strong><\/p>\n<p>\u4ee5\u4e0b\u5206\u522b\u662fcss3\u5b9e\u73b0\u4e0eapi\u5b9e\u73b0\u7684\u6838\u5fc3\u4ee3\u7801\uff1a<\/p>\n<p>css3\uff1a<\/p>\n<pre>    &lt;!-- wxml --&gt;\n    &lt;view class='music musicTwo musicRotate {{playTwo ? \" \": \"musicPaused\"}} ' bindtap='playTwo'&gt;\n        &lt;text class=\"iconfont has-music\" wx:if=\"{{playTwo}}\"&gt;&lt;\/text&gt;\n        &lt;text class=\"iconfont no-music\" wx:if=\"{{!playTwo}}\"&gt;&lt;\/text&gt;\n    &lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>    \/\/ scss\n    .musicRotate{\n        animation: rotate 3s linear infinite;\n    }\n    \n    @keyframes rotate{\n        from{\n            transform: rotate(0deg)\n        }\n        to{\n            transform: rotate(359deg)\n        }\n    }\n    \n    .musicPaused{\n        animation-play-state: paused;\n    }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>    \/\/ js\n    playTwo(){\n        this.setData({\n            playTwo: !this.data.playTwo\n        },()=&gt;{\n            let back = this.data.backgroundAudioManager;\n            if(this.data.playTwo){\n                back.play();\n            } else {\n                back.pause();\n            }\n        })\n    }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7playTwo\u8fd9\u4e2a\u5c5e\u6027\u6765\u5224\u65ad\u662f\u5426\u6682\u505c\uff0c\u5e76\u63a7\u5236css\u7c7b\u7684\u6dfb\u52a0\u4e0e\u5220\u9664\u3002\u5f53\u4e3afalse\u65f6\uff0c\u6dfb\u52a0.musicPaused\u7c7b\uff0c\u52a8\u753b\u6682\u505c\u3002<\/p>\n<p>api:<\/p>\n<pre>    &lt;!-- wxml --&gt;\n    &lt;view class='music' bindtap='play'  animation=\"{{play &amp;&amp; musicRotate}}\"&gt;\n        &lt;text class=\"iconfont has-music\" wx:if=\"{{play}}\"&gt;&lt;\/text&gt;\n        &lt;text class=\"iconfont no-music\" wx:if=\"{{!play}}\"&gt;&lt;\/text&gt;\n    &lt;\/view&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>    \/\/ js\n    play(){\n        this.setData({\n            play: !this.data.play\n        },()=&gt;{\n            let back = this.data.backgroundAudioManager;\n            if (!this.data.play) {\n                back.pause();\n               \/\/ \u8de8\u4e8b\u4ef6\u6e05\u9664\u5b9a\u65f6\u5668\n               clearInterval(this.data.rotateInterval);\n            } else {\n                back.play();\n                \/\/ \u7ee7\u7eed\u65cb\u8f6c\uff0cthis.data.i\u8bb0\u5f55\u4e86\u65cb\u8f6c\u7684\u7a0b\u5ea6\n                this.musicRotate(this.data.i);\n            }\n        })\n    },\n    musicRotate(i){\n        let self = this;\n        let rotateFuc = function(){\n            i++;\n            self.setData({\n                i:i++\n            });\n            let animation = wx.createAnimation({\n                duration: 1000,\n                delay: 0,\n                timingFunction: \"linear\",\n            });\n            animation.rotate(30*(i++)).step()\n            self.setData({ musicRotate: animation.export() });\n        }\n        rotateFuc();\n        let rotateInterval = setInterval(\n            rotateFuc,1000\n        );\n        \/\/ \u5168\u5c40\u5b9a\u65f6\u4e8b\u4ef6\n        this.setData({\n            rotateInterval: rotateInterval\n        })\n    }<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u901a\u8fc7api\u5b9e\u73b0\u7684\u65b9\u5f0f\u662f\u901a\u8fc7\u79fb\u9664animationData\u6765\u63a7\u5236\u52a8\u753b\uff0c\u540c\u65f6\u6682\u505c\u52a8\u753b\u4e5f\u9700\u8981\u6e05\u9664\u5b9a\u65f6\u5668\uff0c\u7531\u4e8e\u6e05\u9664\u5b9a\u65f6\u5668\u9700\u8981\u8de8\u4e8b\u4ef6\u8fdb\u884c\u64cd\u4f5c\uff0c\u6240\u4ee5\u5b9a\u4e86\u4e00\u4e2a\u5168\u5c40\u65b9\u6cd5rotateInterval\u3002<\/p>\n<p>api\u65b9\u5f0f\u5b9a\u4e49\u4e86\u65cb\u8f6c\u7684\u89d2\u5ea6\uff0c\u4f46\u65cb\u8f6c\u5230\u8be5\u89d2\u5ea6\u4e4b\u540e\u4fbf\u4f1a\u505c\u6b62\uff0c\u5982\u679c\u9700\u8981\u5b9e\u73b0\u91cd\u590d\u65cb\u8f6c\u6548\u679c\uff0c\u9700\u8981\u901a\u8fc7\u5b9a\u65f6\u5668\u6765\u5b8c\u6210\u3002\u56e0\u6b64\u5b9a\u4e49\u4e86\u53d8\u91cfi\uff0c\u5b9a\u65f6\u5668\u6bcf\u6267\u884c\u4e00\u6b21\u4fbf\u52a01\uff0c\u76f8\u5f53\u4e8e\u6bcf1s\u65cb\u8f6c30\u00b0\uff0c\u5bf9animation.rotate()\u4e2d\u7684\u5ea6\u6570\u52a8\u6001\u8d4b\u503c\u3002\u6682\u505c\u4e4b\u540e\u7ee7\u7eed\u52a8\u753b,\u9700\u8981\u4ece\u539f\u6709\u89d2\u5ea6\u7ee7\u7eed\u65cb\u8f6c\uff0c\u56e0\u6b64\u53d8\u91cfi\u9700\u8981\u4e3a\u5168\u5c40\u53d8\u91cf\u3002<\/p>\n<p>\u4ee3\u7801\u53d8\u5316\uff1a<\/p>\n<p>\u4e0b\u56fe\u53ef\u4ee5\u770b\u51fa\uff0capi\u65b9\u5f0f\u65cb\u8f6c\u662f\u901a\u8fc7\u4e0d\u65ad\u7d2f\u52a0\u89d2\u5ea6\u6765\u5b8c\u6210\uff0c\u800c\u975ecss3\u4e2d\u5faa\u73af\u6267\u884c\u3002<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/\/upload\/image\/323\/122\/283\/1541839123574137.gif\" class=\"aligncenter\" title=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe5\" alt=\"\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u63d2\u56fe5\" \/><\/p>\n<p><strong><span style=\"font-size: 24px\">\u5bf9\u6bd4<\/span><\/strong><\/p>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u4e24\u4e2a\u5c0f\u4f8b\u5b50\u5bf9\u6bd4\uff0c\u65e0\u8bba\u662f\u4fbf\u6377\u5ea6\u8fd8\u662f\u4ee3\u7801\u91cf\uff0c\u901a\u8fc7css3\u6765\u5b9e\u73b0\u52a8\u753b\u6548\u679c\u76f8\u5bf9\u6765\u8bf4\u662f\u66f4\u597d\u7684\u9009\u62e9\u3002api\u65b9\u5f0f\u5b58\u5728\u8f83\u591a\u5c40\u9650\u6027\uff1a<\/p>\n<ol>\n<li>\n<p>\u52a8\u753b\u53ea\u80fd\u6267\u884c\u4e00\u6b21\uff0c\u5faa\u73af\u6548\u679c\u9700\u8981\u901a\u8fc7\u5b9a\u65f6\u5668\u5b8c\u6210\u3002<\/p>\n<\/li>\n<li>\n<p>\u65e0\u6cd5\u6309\u7167\u539f\u6709\u8f68\u8ff9\u8fd4\u56de\uff0c\u9700\u8981\u8fd4\u56de\u5fc5\u987b\u5b9a\u4e49\u5b9a\u65f6\u5668\u3002<\/p>\n<\/li>\n<li>\n<p>\u9891\u7e41\u501f\u52a9\u5b9a\u65f6\u5668\u5728\u6027\u80fd\u4e0a\u6709\u786c\u4f24\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u7efc\u5408\u4ee5\u4e0a\uff0c\u63a8\u8350\u901a\u8fc7css3\u6765\u5b8c\u6210\u52a8\u753b\u6548\u679c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\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\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5e26\u6765\u7684\u5185\u5bb9\u662f\u4ecb\u7ecd\u5982\u4f55\u5b9e\u73b0\u5c0f\u7a0b\u5e8f\u52a8\u753b\uff1f\u5c0f\u7a0b\u5e8f\u52a8\u753b\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u6709\u9700\u8981\u7684\u670b\u53cb\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b\uff0c\u5e0c\u671b\u5bf9\u4f60\u4eec\u6709\u6240\u5e2e\u52a9\u3002 \u5728\u666e\u901a\u7684\u7f51\u9875\u5f00\u53d1\u4e2d\uff0c\u52a8\u753b\u6548\u679c\u53ef\u4ee5\u901a\u8fc73\u6765\u5b9e\u73b0\u5927\u90e8\u5206\u9700\u6c42\uff0c\u5728\u5c0f\u7a0b\u5e8f\u5f00\u53d1\u4e2d\u540c\u6837\u53ef\u4ee5\u4f7f\u7528css3\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u901a\u8fc7api\u65b9\u5f0f\u6765\u5b9e\u73b0\u3002 API\u89e3\u8bfb \u5c0f\u7a0b\u5e8f\u4e2d\uff0c\u901a\u8fc7\u8c03\u7528api\u6765\u521b\u5efa\u52a8\u753b\uff0c\u9700\u8981\u5148\u521b\u5efa\u4e00\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\u3002\u8fd9\u4e2a\u5bf9\u8c61\u901a\u8fc7wx.createAnimation\u8fd4\u56de,animation\u7684\u4e00\u7cfb\u5217\u5c5e\u6027\u90fd\u57fa\u4e8e\u8fd9\u4e2a\u5b9e\u4f8b\u5bf9\u8c61\u3002 \u521b\u5efa\u8fd9\u4e2a\u5bf9\u8c61 let animation = wx.createAnimation({ duration: 2000, delay: 0, timingFunction: &#8220;linear&#8221;, }); \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u4e2aanimation\u5c31\u662f\u901a\u8fc7wx.createAnimation\u4e4b\u540e\u8fd4\u56de\u7684\u5b9e\u4f8b\u3002\u5728\u521b\u5efa\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u7ed9\u8fd9\u4e2a\u5b9e\u4f8b\u6dfb\u52a0\u4e00\u4e9b\u5c5e\u6027\uff0c\u5982\u4ee5\u4e0a\u4ee3\u7801\u6240\u793a\uff0c\u7b49\u540c\u4e8ecss3\u4e2danimation:$name 2s linear\u7684\u5199\u6cd5\u3002 \u6dfb\u52a0\u52a8\u6548 \u5b9e\u4f8b\u521b\u5efa\u5b8c\u6210\u4e4b\u540e\uff0c\u57fa\u4e8e\u8be5\u5b9e\u4f8b\uff0c\u6dfb\u52a0\u9700\u8981\u7684\u52a8\u6001\u6548\u679c\uff0c\u52a8\u6001\u7c7b\u578b\u53ef\u4ee5\u67e5\u9605\u6587\u6863\u5f97\u77e5\uff0c\u4ee5\u6700\u5e38\u89c1\u7684\u79fb\u52a8\uff0c\u65cb\u8f6c\u4e3a\u4f8b\uff1a animation.translate($width, 0).rotate($deg); \u767b\u5f55\u540e\u590d\u5236 \u7ed3\u675f\u52a8\u753b .step()\u8868\u793a\u4e00\u7ec4\u52a8\u753b\u7684\u7ed3\u675f animation.step(); \u767b\u5f55\u540e\u590d\u5236 \u5bfc\u51fa\u52a8\u753b \u52a8\u753b\u6548\u679c\u6dfb\u52a0\u5b8c\u6210\u4e86\uff0c\u5982\u4f55\u7ed9\u60f3\u8981\u7684dom\u6dfb\u52a0\u52a8\u6548\u5462\u3002\u8fd9\u91cc\u9700\u8981\u7528\u5230.export()\u5bfc\u51fa\u52a8\u753b\u961f\u5217\uff0c\u8d4b\u503c\u7ed9\u67d0\u4e2adom\u5bf9\u8c61\u3002 this.setData({ moveOne: animation.export() }) \u767b\u5f55\u540e\u590d\u5236 &lt;view animation=&#8221;{{moveOne}}&#8221;&gt;&lt;\/view&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f8b\u5b50 \u4ee5\u4e0b\u5c06\u901a\u8fc72\u7ec4\u52a8\u753b\uff0c\u6765\u5bf9\u6bd4\u4e00\u4e0bcss3\u4e0eapi\u5b9e\u73b0\u65b9\u5f0f\u7684\u4e0d\u540c\u3002 \u4e00\u3001\u6a21\u5757\u79fb\u52a8\u52a8\u753b \u52a8\u753b\u6548\u679c\uff1a \u4e0b\u56fe\u6709\u4e24\u7ec4\u52a8\u753b\uff0c\u5206\u522b\u4e3aapi\u65b9\u5f0f\uff08\u4e0a\uff09\u4e0ecss3\u65b9\u5f0f\uff08\u4e0b\uff09\u5b8c\u6210\u7684\u6548\u679c\uff0c\u70b9\u51fbmove\u6309\u94ae\uff0c\u52a8\u753b\u542f\u52a8\u3002 \u4ee3\u7801\u5b9e\u73b0 \u4ee5\u4e0b\u5206\u522b\u4e3acss3\u4e0eapi\u7684\u6838\u5fc3\u4ee3\u7801\uff1a css3\uff1a &lt;!&#8211; wxml &#8211;&gt; &lt;view class=&#8217;border&#8217;&gt; &lt;view class=&#8217;css-block {{isMove [&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-28573","post","type-post","status-publish","format-standard","hentry","category-19"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28573","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=28573"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28573\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}