1、将切换的页面用transition包裹

<div class="index-content">
     <transition>
           <router-view/>
     </transition>
</div>

 

2、css设置切换动画

    .index-content{
        width: 100%;
        //解决出现横向滚动条问题
        overflow-x: hidden;
    }
    .v-enter{
        opacity: 0;
        transform: translateX(100%);
    }
    .v-leave-to{
        opacity: 0;
        transform: translateX(-100%);
        // 解决页面从上往下位移问题
        position: absolute;
    }
    .v-enter-active,.v-leave-active{
        transition: all .5s ease;
    }

3.完工。

相关文章:

  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2017-12-22
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案