js
data: {
animationData: {}
},
/**
* 生命周期函数--监听页面加载
*/
onl oad(options) {
this.loop = wx.createAnimation({
delay: 0,
timingFunction: 'ease'
})
let flag = true
setInterval(() => {
if (flag) {
this.loop.right(20).step()
} else {
this.loop.right(0).step()
}
flag = !flag
this.setData({
animationData: this.loop.export()
})
}, 500);
},
wxml
<view class="new-video" animation="{{animationData}}">新剧抢先看</view>
wxss
.new-video {
background-color: yellow;
border-radius: 5px;
padding: 5px 10px;
position: absolute;
top: 0;
right: 0;
}
标签:动画,right,微信,程序,flag,5px,animationData,loop
From: https://www.cnblogs.com/samsara-yx/p/16779428.html