var animationData = wx.createAnimation({
delay:100,
duration: 800,
timingFunction: 'ease'
})
this.animationData = animationData
this.animationData.opacity(1).step()
this.setData({
animate: this.animationData.export()
})
你用下面这种新写法,来代替旧的wx.createAnimation试试:
this.animate('#container1', [ { opacity: 1.0, rotate: 0, backgroundColor: '#FF0000' }, { opacity: 0.5, rotate: 45, backgroundColor: '#00FF00', offset: 0.9}, { opacity: 0.0, rotate: 90, backgroundColor: '#FF0000' }, ], 5000, function () { this.clearAnimation('#container1', { opacity: true, rotate: true }, function () { console.log("清除了#container上的动画属性") }) }.bind(this))
参考文档:https://developers.weixin.qq.com/miniprogram/dev/framework/view/animation.html#%E5%85%B3%E9%94%AE%E5%B8%A7%E5%8A%A8%E7%94%BB