5

vue路由器,初学这样写,不知道错哪了??

vue路由器,初学这样写,不知道错哪了??

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue 测试实例 - 菜鸟教程(runoob.com)</title>
<script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
<script src="https://cdn.staticfile.org/vue-router/2.7.0/vue-router.min.js"></script>
</head>
<body>
    <div id="app">
        <div class="list-group">
            <a class="list-group-item" v-link="{ path: '/home'}">Home</a>
            <a class="list-group-item" v-link="{ path: '/about'}">About</a>
        </div>
        <router-view></router-view>
    </div>
</body>
<script>
    var Home = Vue.extend({
        template: '<div><h1>Home</h1><p>{{msg}}</p></div>',
        data: function() {
            return {
                msg: 'Hello, vue router!'
            }
        }
    })

    var About = Vue.extend({
        template: '<div><h1>About</h1><p>This is the tutorial about vue-router.</p></div>'
    })
    var router = new VueRouter({
        routes:[
        { path: '/home', component: Home },
        { path: '/about', component: About }
        ]

    });
    new Vue({
        el:"#app",
        router
    })
</script>
</body>
</html>
查看全部
fbl123456789
哈哈哈666666
2019/04/26 13:27
  • vue.js
  • 点赞
  • 收藏
  • 回答
    私信

3个回复