• vue2.0学习笔记之路由(二)路由嵌套+动画


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>vue2.0学习笔记之路由(二)路由嵌套+动画</title>
        <link rel="stylesheet" href="animate.css">
    </head>
    <body>
        <div id="app">
            <div>
                <router-link to="/home">主页</router-link>
                <router-link to="/user">用户中心</router-link>
            </div>
            <div>
                <router-view></router-view>
            </div>
        </div>
    </body>
    </html>
    <script src="vue.js"></script>
    <script src="vue-router.js"></script>
    <script>
        // 定义组件
        var Home = {
            template:`
                <transition enter-active-class="animated bounceInLeft" leave-active-class="animated bounceOutRight">
                    <h3>主页内容</h3>
                </transition>
            `
        }
        var User = {
            template:`
                <div>
                    <transition enter-active-class="animated bounceInLeft" leave-active-class="animated bounceOutRight">
                        <h3>用户中心</h3>
                    </transition>
                    <ul>
                        <li><router-link to="user/userinfo">查看个人信息</router-link></li>
                    </ul>
                    <div>
                        <router-view></router-view>
                    </div>
                </div>
    
            `
        }
        var UserDetail = {
            template:"<h4>个人信息</h4>"
        }
        // 配置路由
        const routes = [
            { path:"/home", component:Home },
            {
                path:"/user",
                component:User,
                children:[
                    { path:"userinfo",component:UserDetail }
                ]
            },
            { path:"*", redirect:"/home" } // 重定向让页面加载即显示Home
        ]
        // 生成路由实例
        const router = new VueRouter({
            routes
        })
        // 挂载到vue实例上
        new Vue({
            el:"#app",
            router
        })
    </script>
  • 相关阅读:
    PowerDesigner将PDM导出生成WORD文档
    哨兵机制
    redis 主从数据同步
    redis RDB
    redis AOF机制
    redis数据结构
    dependencyManagement 和 dependencies的区别
    同源策略 跨域资源共享
    高可用 可扩展 多层反向代理架构演进
    String 杂记
  • 原文地址:https://www.cnblogs.com/hcxy/p/7118739.html
Copyright © 2020-2023  润新知