• vue移动端 实现手机左右滑动入场动画


    app.vue

    <template>
    <div id="app">
    <transition :name="transitionName">
    <keep-alive >
    <router-view v-if="$route.meta.keepAlive" class="Router"></router-view>
    </keep-alive>
    </transition >
    <transition :name="transitionName">
    <router-view v-if="!$route.meta.keepAlive" class="Router"></router-view>
    </transition >
    <Play></Play>
    </div>
    </template>
    <script>import Play from './components/play'
    export default {
    name: 'App',
    data () {
    return {
    transitionName: 'slide-left'
    }
    },
    watch: {
    '$route' (to, from) {
    // 切换动画
    let isBack = this.$router.isBack // 监听路由变化时的状态为前进还是后退
    if (isBack === true) {
    this.transitionName = 'slide-right'
    // from.meta.keepAlive = false
    // to.meta.keepAlive = true
    } else {
    // from.meta.keepAlive = true
    // to.meta.keepAlive = false
    // this.transitionName = 'slide-left'
    if (this.$route.path.split('/').length < 3) {
    this.transitionName = 'slide-fade'
    } else {
    this.transitionName = 'slide-left'
    }
    }
    this.$router.isBack = false
    }
    },
    components: {
    Play
    }
    }
    </script>
    
    <style>
    .Router {
    font-family: Roboto, Lato, sans-serif;
    position: absolute;
     100%;
    height: 100%;
    padding-bottom: 60px;
    transition: all .377s ease;
    box-sizing: border-box;
    overflow: auto;
    }
    .slide-left-enter,
    .slide-right-leave-active {
    opacity: 0;
    -webkit-transform: translate(100%, 0);
    transform: translate(100%, 0);
    }
    
    .slide-left-leave-active,
    .slide-right-enter {
    opacity: 0;
    -webkit-transform: translate(-100%, 0);
    transform: translate(-100% 0);
    }
    .ovf {
    overflow: hidden;
    }
    .center {
     95%;
    margin: 0 auto;
    overflow-y: hidden;
    }
    li {
    list-style: none;
    }
    </style>

    路由配置

    {
    path: '/playListDetail/:id',
    name: 'playListDetail',
    component: pather => require(['../components/playListDetail.vue'], pather),
    meta: {
    title: '歌单详情',
    keepAlive: true,
    isBack: false
    }



    返回事件

    back () {
    this.$router.go(-1)
    this.$router.isBack = true
    }
  • 相关阅读:
    团队介绍的词频统计
    对软件工程这门课的理解与自我期望
    第九次作业-用户使用手册及测试报告
    第8八次作业——系统设计和任务分配
    基于 Java Web 的毕业设计选题管理平台--选题报告与需求规格说明书
    结对作业之需求分析与原型设计
    博客与GitHub地址
    Python库
    课程理解
    大数据作业
  • 原文地址:https://www.cnblogs.com/plBlog/p/11431173.html
Copyright © 2020-2023  润新知