[Vuejs]-How to use Vue JS transition "inside" another transition?

0👍

You did not seem to add the transition CSS for the slide component. The following should work:

const vm = new Vue({
  el: '#demo',
  data() {
    return {
      show: true
    }
  }
})
.slide-fade-enter-active,
.slide-fade-leave-active {
  transition: opacity 0.5s;
}

.slide-fade-enter,
.slide-fade-leave-to {
  opacity: 0;
}

.slide-enter-active {
  transition: all 0.3s ease;
}

.slide-leave-active {
  transition: all 0.8s cubic-bezier(1, 0.5, 0.8, 1);
}

.slide-enter,
.slide-leave-to {
  transform: translateX(10px);
  opacity: 0;
}

/* Some styling to make them noticeable */
.parent {
  background-color: lightgray;
  padding: 2px;
}

.child {
  background-color: yellow;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div id="demo">
  <transition name="slide">
    <div v-if="show" class="parent">
      <transition name="slide-fade">
        <p class="child">hello</p>
      </transition>
    </div>
  </transition>

  <button @click="show = !show">Toggle</button>
</div>

Leave a comment