你好,我把animation的创建放在onShow里面,即使规定了duration,在运行时,打开这个页面,动画都是瞬间完成,只有放在setTimeout里,才能体现出duration
onShow: function () {
var animation = wx.createAnimation({
duration: 6000,
timingFunction: 'linear',
delay:500
});
this.animation = animation;
animation.translate(150,0).step({duration:6000,delay:1000});
this.setData({
animationData:animation.export()
})
this.animation = animation;
setTimeout(function () {
animation.translate(-Number(this.data.announcementText.length)*14, 0).step();
this.setData({
animationData: animation.export()
})
}.bind(this), 1000)
},