Home  >  Q&A  >  body text

javascript - Problem with route transition in vue?

Vue adds a cutscene animation fade-in and fade-out effect to the route. The component fades out when it is removed, but when it is entered, it enters instantly and does not fade in. Between these two steps, the page will become blank. The following is my code, copied from the official website:

<template>
  <p id="app">
    <transition name="fade">
      <router-view></router-view>
    </transition>
  </p>
</template>
.fade-enter-active, .fade-leave-active {
  transition: opacity .3s
}
.fade-enter, .fade-leave-active {
  opacity: 0
}


请问要怎么做才可以在当前组件淡出的同时,将要被插入的组件能淡入。
滿天的星座滿天的星座2710 days ago750

reply all(3)I'll reply

  • 世界只因有你

    世界只因有你2017-06-12 09:32:07

    Set mode to out-in

    reply
    0
  • 欧阳克

    欧阳克2017-06-12 09:32:07

    .fade-enter-active, .fade-leave-active {
      opacity: 1;
      transition: opacity .3s
    }
    .fade-enter, .fade-leave-active {
      opacity: 0
    }

    or:

    .fade-enter-active, .fade-leave-active {
      opacity: 1;
      transition: opacity .3s
    }
    .fade-enter, .fade-leave-to {
      opacity: 0;
    }

    reply
    0
  • 怪我咯

    怪我咯2017-06-12 09:32:07

    .fade-enter-active, .fade-leave-active {
    opacity: 1;
    transition: opacity .3s
    }
    .fade-enter, .fade-leave {
    opacity: 0
    }

    reply
    0
  • Cancelreply