微信小程序--动画

1.把animate.wxss文件放进工程中,在app.wxss中引入
@import "文件路径/animate.wxss";
2.需要加动画的标签设置如下
<view>
<text class='animated bounce'>微信小程序</text>
</view>

如果需要重复动画效果,只需要加上infinite

<view>
<text class='animated bounce infinite'>微信小程序</text>
</view>

解释animated必须要写,这样才能真正使用, bounceanimate.wxss的其中一个动画,你可以选择你需要的动画,当然了,你也可以修改动画的参数来满足项目中的需求!!!

3.可以通过*.js中动态改变动画效果
//.wxml
<view class='containView'>
<text class='{{animationType}}'>微信小程序</text>
</view>

//.js
/**
   * 页面的初始数据
   */
  data: {
    animationType:"animated bounce" //初始的动画效果
  }

  //按钮点击
  clickBtn:function(){
    // "animated bounce infinite"
      this.setData({
        animationType: "animated " + 动画名称  //别忘了加空格
      })
}
这样就实现了动画改变,是不是很简单呀!!!

猜你喜欢

转载自blog.csdn.net/weixin_41871290/article/details/80974467