微信小程序:动画(Animation)

效果图:

 代码:

//wxml


<view class="container">
  <view class="usermotto" animation="{{ani}}">
    <text class="user-motto">{{motto}}</text>
  </view>
  <button bindtap='start'>动画</button>
</view>


//wxss


.usermotto {
  margin-top: 100px;
  border: solid;
}




//js

Page({
  data: {
    motto: 'Hello World',
  },
  start () {
    var animation = wx.createAnimation({
      duration: 4000,
      timingFunction: 'ease',
      delay: 1000
    });
    animation.opacity(0.2).translate(100, -100).step()
    this.setData({
      ani: animation.export()
    })
  }
})

参考链接: https://cloud.tencent.com/developer/article/1367247

原文地址:https://www.cnblogs.com/520BigBear/p/11642252.html