zoukankan      html  css  js  c++  java
  • 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')


  • 相关阅读:
    linux中内存使用,swap,cache,buffer的含义总结
    haproxy启动时提示失败
    pcs与crmsh命令比较
    用yum下载rpm包(不安装)到指定目录
    Openstack的镜像属性
    ceph 对接openstack liberty
    ceph 创建和删除osd
    linux之fstab文件详解
    OpenStack Swift集群部署流程与简单使用
    swift(Object Storage对象存储服务)(单节点)
  • 原文地址:https://www.cnblogs.com/qhhw/p/5945891.html
Copyright © 2011-2022 走看看