码迷,mamicode.com
首页 > 其他好文 > 详细

vue 页面过渡效果

时间:2018-08-27 21:23:32      阅读:484      评论:0      收藏:0      [点我收藏+]

标签:pos   position   index   dex   osi   router   set   uid   export   

App.vue

模板

<template>
  <div id="app">
      <transition :name="transition">
          <keep-alive>
              <router-view v-if="$route.meta.keepAlive"></router-view>
          </keep-alive>
      </transition>
      <transition :name="transition">
          <router-view v-if="!$route.meta.keepAlive"></router-view>
      </transition>
  </div>
</template>

js

<script>
export default {
  name: "App",
  data() {
    return {
      transition: ""
    };
  },
  created(){
    var uid = this.$route.query.uid;
        uid = uid ? uid : 1;
    this.my.setSession(‘tbk_uid‘,uid);
  },
  watch: {
    $route(to, from) {
      if (to.meta.index > from.meta.index) {
        this.transition = "slide-left";
      } else {
        this.transition = "slide-right";
      }
    }
  },
}
</script>

样式

.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
  will-change: transform;
  transition: all 500ms;
  position: absolute;
  width:100%;
  height:100%;
}
.slide-right-enter {
  opacity: 0;
  transform: translate3d(-100%, 0, 0);
}
.slide-right-leave-active {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}
.slide-left-enter {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}
.slide-left-leave-active {
  opacity: 0;
  transform: translate3d(-100%, 0, 0);
}

vue 页面过渡效果

标签:pos   position   index   dex   osi   router   set   uid   export   

原文地址:https://www.cnblogs.com/xielisen/p/9544047.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!