vue-过渡效果(transition过渡组件)

借用animate.css添加类名
使用transition包裹过渡组件
动画:
    enter-active-class = "animated xxxx类名" ---- 进入
    leave-active-class = "animated xxxx类名"  ---- 离开
    mode:
       - 新元素先进行过渡,完成后当前元素过渡离开   --- in-out
       - 当前元素先进行过渡,完成之后新元素过渡进入   --- out-in
<link href="https://cdn.bootcss.com/animate.css/3.7.2/animate.min.css" rel="stylesheet">
  <style>
    p{
      width: 100px;
      height: 100px;
      background: red;
    }
  </style>
</head>
<body>
  <div id="app">
    <button @click = "changeFlag"> changeFlag </button>
    <!-- mode  有两个值   in-out    out-in  -->
    <transition
      name = "xige"
      mode = "in-out"
      enter-active-class = "animated fadeIn"
      leave-active-class = "animated fadeOut"
    >
      <p v-if = "flag"></p>
    </transition>
  </div>
</body>
<script src="../../../lib/vue.js"></script>
<script>
  new Vue({
    el: '#app',
    data: {
      flag: true 
    },
    methods: {
      changeFlag () {
        this.flag = !this.flag 
      }
    }
  })
</script>
发布了55 篇原创文章 · 获赞 8 · 访问量 1779

猜你喜欢

转载自blog.csdn.net/louting249/article/details/103100393