vue使用animate.css


1.在main.js中引入animate.css

import './assets/animate.css'

2.使用transition标签包裹运动的元素,使用enter-active-class定义进入动画,使用leave-active-class定义离开动画,注意animate.css的所有动画要加animated这个类

   <transition enter-active-class="animated bounce" leave-active-class="animated hinge">
        <div class="box" v-show="show"></div>
    </transition>

例子:

<template>
<div>
    <transition enter-active-class="animated bounce" leave-active-class="animated hinge">
        <div class="box" v-show="show"></div>
    </transition>
    <button @click="toggle()">切换</button>
</div>
</template>
<script>
export default {
  name: "Home",
  data () {
    return {
        show:true
    };
  },
  methods:{
      toggle(){
          this.show = !this.show
      }
  }
}
</script>
<style lang="css" scoped>
.box{
    width: 300px;
    height: 300px;
    background-color: red;
    margin: 0 auto;
}
</style>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM