后一个view顶上去的时候会直接引用前一个view的动画
<view >
<view wx:for="{{testanimations}}" wx:key="{{item.i}}" bindtap=‘test’ data-value="{{item.i}}" animation="{{item.o}}">{{item.i}}</view>
<button bindtap=‘test2’>asd</button>
</view>
data: {
testanimations:[
{
i:0,
o:null
},
{
i: 1,
o: null
},
],
},
test:function(index) {
var that=this
let value=index.currentTarget.dataset.value
let animation = wx.createAnimation({
duration: 1000,
timingFunction: ‘ease’
})
animation.translateX(500).step()
var animationsTemp = this.data.testanimations
animationsTemp[value].o = animation.export()
this.setData({
testanimations: animationsTemp
})
setTimeout(function(){
var animationsTemp2 = that.data.testanimations
animationsTemp2.splice(value,1)
that.setData({
testanimations: animationsTemp2
})
},1000)
}