html代码
<view class="page-block guess-u-like">
<view class="single-like-movie" v-for="(guessULike,index) in guessULikeList" :key="index">
<image :src="guessULike.cover" class="like-movie-img"></image>
<view class="movie-desc">
<view class="movie-title">{{ guessULike.name }}</view>
<trailerStars :score="guessULike.score" :showNumber="0" ></trailerStars>
<view class="movie-info">{{ guessULike.basicInfo }}</view>
<view class="movie-info">{{ guessULike.releaseDate }}</view>
</view>
<view class="movie-oper" @click="praiseMe" :data-index="index">
<image src="../../static/icos/praise.png" class="praise-ico"></image>
<view class="praise-me">点赞</view>
<view :animation="animationArray[index]" class="praise-me animation-opacity">+1</view>
</view>
</view>
</view>
数据初始化
data() {
return {
carouselList: [],
hotSuperHeroList: [],
hotTrailerList: [],
guessULikeList: [],
animation_temp: {},
animationArray: [
{},{},{},{},{}
]
}
}
onLoad() {
// #ifdef APP-PLUS || MP-WEIXIN
//页面加载完成的时候,创建一个临时的对象
this.animation = uni.createAnimation();
// #endif
}
点击调用方法
praiseMe(e){
var index = e.currentTarget.dataset.index;
//构建动画数据,并通过step来表示这组动画的完成
this.animation.translateY(-60).opacity(1).step({ duration:400 });
this.animation_temp = this.animation;//我不加上这段动画就实现不了,这个是什么情况
this.animationArray[index] = this.animation.export();
//初始化动画,动画立即完成
setTimeout(function() {
this.animation.translateY(0).opacity(0).step(0);
this.animationArray[index]= this.animation.export();
}.bind(this), 500);
}
this.animation_temp = this.animation;//我不加上这段动画就实现不了,这个是什么情况**
1***@qq.com
大神,正解。
2020-07-05 20:52