• vue-router transition 路由切换效果


    所需更改文件  App.vue

     1 //template结构:
     2 
     3 <template> 
     4   <div id="app"> 
     5     <div id="nav">
     6       <router-link to="/come">Come</router-link>
     7     </div>
     8   <transition :name="transitionName"> 
     9       <router-view class="child-view"></router-view> 
    10   </transition> 
    11   </div> 
    12 </template>
    13 
    14 //script结构:
    15 
    16 <script> 
    17 
    18 export default { 
    19   name: 'app', 
    20   data () { 
    21     return { 
    22       transitionName: 'slide-left' 
    23     } 
    24   }, 
    25 mounted () { 
    26 },
    27 
    28 //监听路由的路径,可以通过不同的路径去选择不同的切换效果 
    29 watch: {
    30   '$route' (to, from) {
    31   //    console.log('现在路由:',to.path.split('/')[1],'来自路由:',from.path.split('/')[1],'现在的动画:',this.transitionName)
    32     const toDepth = to.path.split('/').length
    33     const fromDepth = from.path.split('/').length
    34     this.transitionName = toDepth < fromDepth ? 'slide-right' : 'slide-left'
    35     }
    36   }
    37 
    38 } 
    39 </script>
    40 
    41 //style结构:
    42 
    43 <style>
    44 
    45 .child-view { 
    46   margin: 300px auto; 
    47    100%; 
    48   height: 100%; 
    49   transition: all .5s cubic-bezier(.55,0,.1,1); 
    50 } 
    51 .slide-left-enter, .slide-right-leave-active { 
    52   opacity: 0; 
    53   -webkit-transform: translate(30px, 0); 
    54   transform: translate(30px, 0); 
    55 } 
    56 .slide-left-leave-active, .slide-right-enter { 
    57   opacity: 0; 
    58   -webkit-transform: translate(-30px, 0); 
    59   transform: translate(-30px, 0); 
    60 }
    61 </style>

      如需交流可加博主QQ:602697966(备注博客园)

  • 相关阅读:
    调用外部程序主窗体做子窗体
    查看window编码
    c# 数据库更新和界面刷新的问题
    c# datagridview代码(网上的)
    winform DataGridView控件的打印
    西电ubuntu更新软件源
    C++ primer 学习笔记(2):函数
    C++ Primer 学习笔记(1)——迭代器,数组
    查询表属于哪个数据
    oracle 实用语句
  • 原文地址:https://www.cnblogs.com/yzyh/p/7298038.html
Copyright © 2020-2023  润新知