• vue router 跳转动画


    <template>
        <div id="app">
            <transition :name="SkipSwitchName">
                <router-view class="page" />
            </transition>
        </div>
    </template>
    <script>
    export default {
        data() {
            return {
                SkipSwitchName: ""
            };
        },
        watch: {
            $route(to, from) {
                if (to.meta.id > from.meta.id) {
                    this.SkipSwitchName = "slide-left";
                } else {
                    this.SkipSwitchName = "slide-right";
                }
            }
        }
    };
    </script>
    <style>
    .page {
        position: absolute;
        width: 100%;
        box-sizing: border-box;
        background-color: #ededed;
    }
    .slide-right-enter-active,
    .slide-right-leave-active,
    .slide-left-enter-active,
    .slide-left-leave-active {
        will-change: transform;
        transition: all 250ms;
        position: absolute;
    }
    .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);
    }
    </style>

     路由添加 meta id:

    const routes = [
        // VueRouter
        {
            path: '/',
            name: 'Login',
            component: () => import('../views/login'),
            meta: {
                id: 1
            }
        },
        {
            path: '/home',
            name: 'Home',
            component: () => import('../views/home'),
            meta: {
                id: 2
            }
        },
        {
            path: '/transfer',
            name: 'Tansfer',
            component: () => import('../views/transfer'),
            meta: {
                id: 3
            }
        }
    ]
  • 相关阅读:
    MAC记住 git的用户名密码
    webpack初学踩坑记
    __dirname和__filename和process.cwd()三者的区别
    webpack
    日期格式在ios中的兼容性
    php实现导出excel功能
    node 之koa项目学习
    nodejs之socket.io 私发消息和选择群组发消息
    nodejs之socket.io 聊天实现
    mongoDB基础语法
  • 原文地址:https://www.cnblogs.com/deajax/p/12310716.html
Copyright © 2020-2023  润新知