87,907
社区成员
发帖
与我相关
我的任务
分享
<view class='add {{move}}'>+1</view>
<button bindtap='add'>{{num}}</button>
@keyframes move{
0%{
opacity: 1;
transform: translateY(100%);
}
100%{
opacity: 0;
transform: translateY(-400%);
}
}
.move{
animation: move 1s linear 0s forwards;
}
.add{
font-size: 12px;
color: red;
transform: translateY(100%);
opacity: 0;
}
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
num:0
},
/**
* 组件的方法列表
*/
methods: {
add:function(){
const {num}=this.data;
this.setData({
num: num + 1,
move: 'move'
});
setTimeout(()=>{
this.setData({
move: ''
});
},1000);
}
}
})