• Vue.js相关知识4-路由


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
    .v-link-active {
    color: red;
    }
    </style>
    </head>
    <body>

    <div id="app">
    <h1>Hello App!</h1>
    <p>
    <a v-link="{ path: '/foo' }">Go to /foo</a>
    <a v-link="{ path: '/foo/bar' }">Go to /foo/bar</a>
    <a v-link="{ path: '/foo/baz' }">Go to /foo/baz</a>
    <a v-link="{ path: '/doom' }">Go to /foo</a>
    </p>
    <router-view></router-view>
    </div>


    <script src="vue.js"></script>
    <script src="vue-resource.min.js"></script>
    <script src="vue-router.js"></script>
    <script src="vue-router-test-2.js"></script>
    </body>
    </html>


    // define some components
    var Foo = Vue.extend({
    template:
    '<div class="foo">' +
    '<h2>This is Foo!</h2>' +
    '<router-view></router-view>' + // <- nested outlet
    '</div>'
    })

    var Bar = Vue.extend({
    template: '<p>This is bar!</p>'
    })

    var Baz = Vue.extend({
    template: '<p>This is baz!</p>'
    })

    // configure router
    var router = new VueRouter()

    var Doom = Vue.extend({
    template:"<div>末日爸爸</div>"
    })
    router.map({
    '/foo': {
    component: Foo,
    // add a subRoutes map under /foo
    subRoutes: {
    '/': {
    // This component will be rendered into Foo's <router-view>
    // when /foo is matched. Using an inline component definition
    // here for convenience.
    component: {
    template: '<p>Default sub view for Foo</p>'
    }
    },
    '/bar': {
    // Bar will be rendered inside Foo's <router-view>
    // when /foo/bar is matched
    component: Bar
    },
    '/baz': {
    // same for Baz, but only when /foo/baz is matched
    component: Baz
    }
    }
    },
    '/doom':{
    component:Doom
    }
    })

    // start app
    var App = Vue.extend({})
    router.start(App, '#app')


  • 相关阅读:
    苹果 01背包
    Robberies 01背包变形 hdoj
    01背包
    小希的迷宫--并查集
    德克萨斯长角牛 --最短路径
    1596 最短路径的变形
    hibernate重要知识点总结
    Apache与Tomcat整合的配置
    java串口通讯环境配置
    使用spring的aop对Struts2的Action拦截后出现依赖注入为空问题
  • 原文地址:https://www.cnblogs.com/qhhw/p/5945891.html
Copyright © 2020-2023  润新知