dom:
<view :animation="barr.animationIndex" v-for="(barr,index) in dataBarrage" :key="index">{{barr.value}}</view>
js:
var _this = this;
for (let i = 0; i < _this.dataBarrage.length; iPP) {
var num = Math.random(); //
var item = _this.dataBarrage[i];
_this.$set(item, "x", _this.windowWidth + 200 * num);
_this.$set(item, "y", num * 100 + 30);
_this.$set(item, "animationIndex", "animationAll" + i); //
//
_this.animation.translate(item.x, item.y).step({ duration: 10 });
item.animationIndex = _this.animation.export(); //
setTimeout(function() {
_this.animation.translate(-_this.windowWidth - 300, item.y).step();
item.animationIndex = _this.animation.export();
}.bind(_this),1000);
}
I assign a value to item.animationIndex in the setTimeout function. Why only the last value takes effect? the first assignment of item.animationIndex before is all correct after the loop. In the setTimeout function, only the last assignment to item.animationIndex takes effect. What"s going on? How should I write it?