# 内置动画

  • 内置动画皆为db开头的名称

# left_show 入场动画

Add Remove 1 2 3 4 5 6 7 8 9
<template>
  <div id="list-demo" class="demo">
    <db-button v-on:click="add">Add</db-button>
    <db-button v-on:click="remove">Remove</db-button>
    <db-transition-group class-name="db_left_show" enterActiveClass="db_left_show" leaveActiveClass="db_right_hidden" first-play>
      <db-button v-for="item in items" v-bind:key="item" style="margin-top:10px;display: block;" class="list-item">
        {{ item }}
      </db-button>
    </db-transition-group>
  </div>
</template>
<script>
export default {
  data(){
    return {
    items: [1,2,3,4,5,6,7,8,9],
    nextNum: 10
  }
  },
  methods: {
    randomIndex: function () {
      return Math.floor(Math.random() * this.items.length)
    },
    add: function () {
      this.items.splice(this.randomIndex(), 0, this.nextNum++)
    },
    remove: function () {
      this.items.splice(this.randomIndex(), 1)
    },
  }
}
</script>
<style>
.list-item {
  display: inline-block;
  margin-right: 10px;
}
.list-enter-active, .list-leave-active {
  transition: all 1s;
}
.list-enter, .list-leave-to
/* .list-leave-active for below version 2.1.8 */ {
  opacity: 0;
  transform: translateY(30px);
}
</style>
Expand Copy

# 左右出入场动画

切换
<template>
  <div>
    <db-button @click="show = !show">切换</db-button>
    <db-transition enterActiveClass="db_left_show" leaveActiveClass="db_right_hidden">
      <div style="margin-top:10px;" v-if="show">
        showshow
      </div>
    </db-transition>
  </div>
</template>
<script>
export default {
  data () {
    return {
      show: false
    }
  }
}
</script>
Expand Copy

# 上下出入场动画

切换
<template>
  <div>
    <db-button @click="show = !show">切换</db-button>
    <db-transition enterActiveClass="db_top_show" leaveActiveClass="db_bottom_hidden">
      <div style="margin-top:10px;" v-if="show">
        showshow
      </div>
    </db-transition>
  </div>
</template>
<script>
export default {
  data () {
    return {
      show: false
    }
  }
}
</script>
Expand Copy