微信小程序連續旋轉動畫 https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-animation.htmlhtml
<view animation="{{animationData}}" style="background:red;height:100rpx;width:100rpx; bottom:10px;position: absolute;"></view>
Page({ data: { animationData: {} }, onShow: function () { var animation = wx.createAnimation({ duration: 500, timingFunction: 'ease', }) this.animation = animation // animation.scale(2, 2).rotate(45).step() this.setData({ animationData: animation.export() }) var n = 0;
//連續動畫須要添加定時器,所傳參數每次+1就行 setInterval(function () { // animation.translateY(-60).step() n=n+1; console.log(n); this.animation.rotate(180 * (n)).step() this.setData({ animationData: this.animation.export() }) }.bind(this), 1000) }, })