const animation = wx.createAnimation({
duration: 1000,
timingFunction: 'ease-in-out'
});
this.animation = animation;
animation.rotate(180).step();
this.setData({
animationIcon: animation.export()
})
var n = 0;
setInterval(function() {
n = n + 1;
this.animation.rotate(180 * (n + 1)).step()
this.setData({
animationIcon: this.animation.export()
})
}.bind(this), 3000)
我就是想做个3秒旋转一圈的沙漏动画,在模拟上是正常的,3秒会转180°,但是在真机上是一次转好多圈
能麻烦制作个代码片段吗?光看这段代码好像没什么问题呢
https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html
就一个页面,没有其他啥东西了
放在onshow方法里,然后页面一个image,设置一个动画,初始是隐藏的,后面显示
onShow: function() {
const animation = wx.createAnimation({
duration: 1000,
timingFunction: 'ease-in-out'
});
this.animation = animation;
animation.rotate(180).step();
this.setData({
animationIcon: animation.export()
})
var n = 0;
setInterval(function() {
n = n + 1;
this.animation.rotate(180 * (n + 1)).step()
this.setData({
animationIcon: this.animation.export()
})
}.bind(this), 3000)
},
页面
<image animation="{{animationIcon}}" class='precess-icon' src='../../src/img/precess.png'></image>