wx. createAnimation 有关这个api的一个小bug
在一个循环的列表中的其中一项绑定一个animation,
在animation执行完成之后,
删除这一项,
然后再次更新列表,
这个动画依然在被删除的下一项中体现,
看代码
< view class = "test" > < view wx:for = "{{list}}" wx:for-item = "item" wx:for-index = "index" bindtap = "tap" data-index = "{{index}}" animation = "{{item.animation}}" wx:key = "{{item.id}}" > 测试测试测试测试{{item.id}} </ view > </ view > |
Page({ data: { list: [ { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }, { id: 5 }, ] }, tap (e) { console.log(e) let list = this .data.list var animation = wx.createAnimation({ duration: 1000, timingFunction: 'ease' , }) this .animation = animation animation.scale(2, 2).rotate(45).step() let index = e.currentTarget.dataset.index list[index].animation = animation.export() this .setData({ list }) setTimeout(() => { list.splice(index, 1) this .setData({ list }) console.log( this .data.list) }, 1000) } }) |